fix if evaluation.

This commit is contained in:
Kelvin Sherlock 2016-02-02 21:57:42 -05:00
parent 44b42e4fe4
commit 54e1491e6f
1 changed files with 9 additions and 2 deletions

View File

@ -292,6 +292,12 @@ int begin_command::execute(Environment &env, const fdmask &fds, bool throwup) {
namespace {
/*
* returns:
* <0 -> error
* 0 -> false
* >0 -> true
*/
int evaluate(int type, const std::string &s, Environment &env) {
@ -360,8 +366,9 @@ int if_command::execute(Environment &env, const fdmask &fds, bool throwup) {
{
indent_helper indent(env);
int tmp = evaluate(c->type, s, env);
if (tmp < 0) { ok = true; rv = tmp; }
else rv = c->execute(env, newfds);
if (tmp < 0) { ok = true; rv = tmp; continue; }
if (tmp == 0) continue;
rv = c->execute(env, newfds);
}
}