diff --git a/bintest/07_if_statement.rb b/bintest/07_if_statement.rb index c502a77..066e1c1 100644 --- a/bintest/07_if_statement.rb +++ b/bintest/07_if_statement.rb @@ -53,4 +53,16 @@ assert_equal("tp2\n", File.read(tp2), command) end end + + command = "if true; then echo FOO; fi && echo BAR" + assert_equal("FOO\nBAR\n", run(command)[0], command) + + command = "if true; then echo FOO; false; fi && echo BAR" + assert_equal("FOO\n", run(command)[0], command) + + command = "if false; then echo NG; fi || echo OK" + assert_equal("OK\n", run(command)[0], command) + + command = "if true; then echo OK; fi | cat" + assert_equal("OK\n", run(command)[0], command) end diff --git a/mrblib/reddish/executor.rb b/mrblib/reddish/executor.rb index 6232e0e..ac6d28f 100644 --- a/mrblib/reddish/executor.rb +++ b/mrblib/reddish/executor.rb @@ -165,6 +165,9 @@ def if_statement(statement) elsif statement.cmd2 exec(statement.cmd2) end + + # return last status + $? end end