aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-02-12 01:39:06 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-02-12 01:39:06 -0800
commit29ddb68da428804148a0c6f44229cf1848bebf8c (patch)
tree7f304efea5fb102d04b47d59410ab74fa1317918
parentdd49399e45558b1ee494a01628b7cbfbcf0919ff (diff)
Tests and fix to allow return to work correctly within if statements. Closes #1297.
-rw-r--r--parse_execution.cpp6
-rw-r--r--tests/test1.in9
-rw-r--r--tests/test1.out1
3 files changed, 16 insertions, 0 deletions
diff --git a/parse_execution.cpp b/parse_execution.cpp
index 08f222ed..11aa5325 100644
--- a/parse_execution.cpp
+++ b/parse_execution.cpp
@@ -325,6 +325,12 @@ parse_execution_result_t parse_execution_context_t::run_if_statement(const parse
{
run_job_list(*job_list_to_execute, ib);
}
+
+ /* It's possible there's a last-minute cancellation, in which case we should not stomp the exit status (#1297) */
+ if (should_cancel_execution(ib))
+ {
+ result = parse_execution_cancelled;
+ }
/* Done */
parser->pop_block(ib);
diff --git a/tests/test1.in b/tests/test1.in
index 7f60a4da..529baea1 100644
--- a/tests/test1.in
+++ b/tests/test1.in
@@ -121,3 +121,12 @@ echo -e Catch your breath
echo -e 'abc\x21def'
echo -e 'abc\x211def'
+
+function always_fails
+ if true
+ return 1
+ end
+end
+
+always_fails ; echo $status
+
diff --git a/tests/test1.out b/tests/test1.out
index b3460cdd..893e0464 100644
--- a/tests/test1.out
+++ b/tests/test1.out
@@ -36,3 +36,4 @@ abc
Catch your breath
abc!def
abc!1def
+1