summaryrefslogtreecommitdiffstats
path: root/sinksh/syntaxtree.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-10-31 14:04:03 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-10-31 14:04:03 +0100
commite1a3aebafca9a9447a393100db4fc45943551630 (patch)
tree39672297b576e967bd2448d6a795e5485f6995b7 /sinksh/syntaxtree.cpp
parent77b2173e73f16f33648226543788ea67096fb6d6 (diff)
downloadsink-e1a3aebafca9a9447a393100db4fc45943551630.tar.gz
sink-e1a3aebafca9a9447a393100db4fc45943551630.zip
Ensure we get an appropriate exit code when a resource crashes.
Diffstat (limited to 'sinksh/syntaxtree.cpp')
-rw-r--r--sinksh/syntaxtree.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/sinksh/syntaxtree.cpp b/sinksh/syntaxtree.cpp
index ee9d6f8..65eb769 100644
--- a/sinksh/syntaxtree.cpp
+++ b/sinksh/syntaxtree.cpp
@@ -57,16 +57,16 @@ Syntax::List SyntaxTree::syntax() const
57 return m_syntax; 57 return m_syntax;
58} 58}
59 59
60bool SyntaxTree::run(const QStringList &commands) 60int SyntaxTree::run(const QStringList &commands)
61{ 61{
62 bool success = false; 62 int returnCode = 0;
63 m_timeElapsed.start(); 63 m_timeElapsed.start();
64 Command command = match(commands); 64 Command command = match(commands);
65 if (command.first) { 65 if (command.first) {
66 if (command.first->lambda) { 66 if (command.first->lambda) {
67 success = command.first->lambda(command.second, m_state); 67 bool success = command.first->lambda(command.second, m_state);
68 if (success && command.first->interactivity == Syntax::EventDriven) { 68 if (success && command.first->interactivity == Syntax::EventDriven) {
69 success = m_state.commandStarted(); 69 returnCode = m_state.commandStarted();
70 } 70 }
71 } else if (command.first->children.isEmpty()) { 71 } else if (command.first->children.isEmpty()) {
72 m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken"); 72 m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken");
@@ -85,7 +85,7 @@ bool SyntaxTree::run(const QStringList &commands)
85 if (m_state.commandTiming()) { 85 if (m_state.commandTiming()) {
86 m_state.printLine(QObject::tr("Time elapsed: %1").arg(m_timeElapsed.elapsed())); 86 m_state.printLine(QObject::tr("Time elapsed: %1").arg(m_timeElapsed.elapsed()));
87 } 87 }
88 return false; 88 return returnCode;
89} 89}
90 90
91SyntaxTree::Command SyntaxTree::match(const QStringList &commandLine) const 91SyntaxTree::Command SyntaxTree::match(const QStringList &commandLine) const