mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2024-12-28 09:29:57 +00:00
adjust indents
This commit is contained in:
parent
6f53faeae7
commit
1339c0891f
20
command.cpp
20
command.cpp
@ -304,10 +304,9 @@ int begin_command::execute(Environment &env, const fdmask &fds, bool throwup) {
|
|||||||
if (status) return env.status(status);
|
if (status) return env.status(status);
|
||||||
|
|
||||||
int rv;
|
int rv;
|
||||||
{
|
env.indent_and([&]{
|
||||||
indent_helper indent(env);
|
rv = vector_command::execute(env, newfds);
|
||||||
rv = vector_command::execute(env, newfds);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
env.echo("%s", type == BEGIN ? "end" : ")");
|
env.echo("%s", type == BEGIN ? "end" : ")");
|
||||||
|
|
||||||
@ -388,13 +387,14 @@ int if_command::execute(Environment &env, const fdmask &fds, bool throwup) {
|
|||||||
env.echo("%s", s.c_str());
|
env.echo("%s", s.c_str());
|
||||||
|
|
||||||
if (ok) continue;
|
if (ok) continue;
|
||||||
{
|
|
||||||
indent_helper indent(env);
|
int tmp = evaluate(c->type, s, env);
|
||||||
int tmp = evaluate(c->type, s, env);
|
if (tmp < 0) { ok = true; rv = tmp; continue; }
|
||||||
if (tmp < 0) { ok = true; rv = tmp; continue; }
|
if (tmp == 0) continue;
|
||||||
if (tmp == 0) continue;
|
|
||||||
|
env.indent_and([&](){
|
||||||
rv = c->execute(env, newfds);
|
rv = c->execute(env, newfds);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
env.echo("end");
|
env.echo("end");
|
||||||
|
@ -91,6 +91,13 @@ public:
|
|||||||
|
|
||||||
void echo(const char *format, ...);
|
void echo(const char *format, ...);
|
||||||
|
|
||||||
|
template<class FX>
|
||||||
|
void indent_and(FX &&fx) {
|
||||||
|
int i = _indent++;
|
||||||
|
try { fx(); _indent = i; }
|
||||||
|
catch (...) { _indent = i; throw; }
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// magic variables.
|
// magic variables.
|
||||||
|
|
||||||
@ -111,6 +118,7 @@ private:
|
|||||||
std::unordered_map<std::string, EnvironmentEntry> _table;
|
std::unordered_map<std::string, EnvironmentEntry> _table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
class indent_helper {
|
class indent_helper {
|
||||||
public:
|
public:
|
||||||
indent_helper(Environment &e) : env(e) { env._indent++; }
|
indent_helper(Environment &e) : env(e) { env._indent++; }
|
||||||
@ -120,6 +128,6 @@ private:
|
|||||||
Environment &env;
|
Environment &env;
|
||||||
bool active = true;
|
bool active = true;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user