mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
Make if statements always return success at the end, matching other
shells. Fixes #1061.
This commit is contained in:
parent
09054a09fa
commit
e632d39b1f
4 changed files with 16 additions and 0 deletions
|
@ -3773,6 +3773,10 @@ static int builtin_end(parser_t &parser, wchar_t **argv)
|
|||
}
|
||||
|
||||
case IF:
|
||||
/* Always return success (#1061) */
|
||||
proc_set_last_status(0);
|
||||
break;
|
||||
|
||||
case SUBST:
|
||||
case BEGIN:
|
||||
case SWITCH:
|
||||
|
|
|
@ -306,6 +306,12 @@ parse_execution_result_t parse_execution_context_t::run_if_statement(const parse
|
|||
/* Done */
|
||||
parser->pop_block(ib);
|
||||
|
||||
/* Issue 1061: If we executed, then always report success, instead of letting the exit status of the last command linger */
|
||||
if (result == parse_execution_success)
|
||||
{
|
||||
proc_set_last_status(STATUS_BUILTIN_OK);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,3 +23,7 @@ echo (seq $n)[3..5 -2..2]
|
|||
echo Test more
|
||||
echo $test[(count $test)..1]
|
||||
echo $test[1..(count $test)]
|
||||
|
||||
# See issue 1061
|
||||
echo "Verify that if statements swallow failure"
|
||||
if false ; end ; echo $status
|
||||
|
|
|
@ -15,3 +15,5 @@ Test command substitution
|
|||
Test more
|
||||
10 9 8 7 6 5 4 3 2 1
|
||||
1 2 3 4 5 6 7 8 9 10
|
||||
Verify that if statements swallow failure
|
||||
0
|
||||
|
|
Loading…
Reference in a new issue