mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2026-01-26 12:16:33 +00:00
control-c support
This commit is contained in:
11
command.cpp
11
command.cpp
@@ -4,6 +4,7 @@
|
||||
#include "fdset.h"
|
||||
#include "builtins.h"
|
||||
#include "mpw-shell.h"
|
||||
#include "error.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
@@ -16,6 +17,8 @@
|
||||
#include <sys/wait.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
extern volatile int control_c;
|
||||
|
||||
namespace {
|
||||
|
||||
std::string &lowercase(std::string &s) {
|
||||
@@ -121,6 +124,9 @@ command::~command()
|
||||
*/
|
||||
|
||||
int simple_command::execute(Environment &env, const fdmask &fds, bool throwup) {
|
||||
|
||||
if (control_c) throw execution_of_input_terminated();
|
||||
|
||||
std::string s = expand_vars(text, env);
|
||||
|
||||
env.echo("%s", s.c_str());
|
||||
@@ -160,6 +166,8 @@ int simple_command::execute(Environment &env, const fdmask &fds, bool throwup) {
|
||||
|
||||
int evaluate_command::execute(Environment &env, const fdmask &fds, bool throwup) {
|
||||
|
||||
if (control_c) throw execution_of_input_terminated();
|
||||
|
||||
std::string s = expand_vars(text, env);
|
||||
|
||||
env.echo("%s", s.c_str());
|
||||
@@ -215,6 +223,9 @@ int vector_command::execute(Environment &e, const fdmask &fds, bool throwup) {
|
||||
}
|
||||
|
||||
int error_command::execute(Environment &e, const fdmask &fds, bool throwup) {
|
||||
|
||||
if (control_c) throw execution_of_input_terminated();
|
||||
|
||||
std::string s = expand_vars(text, e);
|
||||
|
||||
e.echo("%s", s.c_str());
|
||||
|
||||
Reference in New Issue
Block a user