mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2024-06-17 22:29:47 +00:00
Echo support (for testing)
This commit is contained in:
parent
1219a40d07
commit
e4a124f514
24
command.cpp
24
command.cpp
|
@ -7,6 +7,8 @@ command::~command()
|
||||||
|
|
||||||
|
|
||||||
int simple_command::execute() {
|
int simple_command::execute() {
|
||||||
|
// echo
|
||||||
|
fprintf(stderr, " %s\n", text.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +52,14 @@ int vector_command::execute() {
|
||||||
int begin_command::execute() {
|
int begin_command::execute() {
|
||||||
// todo -- parse end for redirection.
|
// todo -- parse end for redirection.
|
||||||
|
|
||||||
int rv = vector_command::execute();
|
// echo!
|
||||||
|
fprintf(stderr, " %s ... %s\n",
|
||||||
|
type == BEGIN ? "begin" : "(",
|
||||||
|
end.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
int rv = vector_command::execute();
|
||||||
|
fprintf(stderr, " %s\n", type == BEGIN ? "end" : ")");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,13 +67,25 @@ int if_command::execute() {
|
||||||
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
|
|
||||||
// todo -- parse end for redirection.
|
// todo -- parse end for redirection.
|
||||||
for(auto &c : clauses) {
|
for (auto &c : clauses) {
|
||||||
|
if (c->type == IF) {// special.
|
||||||
|
fprintf(stderr, " %s ... %s\n",
|
||||||
|
c->clause.c_str(), end.c_str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, " %s\n", c->clause.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if (ok) continue;
|
if (ok) continue;
|
||||||
ok = c->evaluate();
|
ok = c->evaluate();
|
||||||
if (!ok) continue;
|
if (!ok) continue;
|
||||||
rv = c->execute();
|
rv = c->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, " end\n");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user