mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
Set $status after while depending on whether loop was entered
Closes #4982.
This commit is contained in:
@@ -69,6 +69,7 @@ fish 3.0 is a major release which brings with it both improvements in functional
|
||||
- Autosuggestions try to avoid arguments that are already present in the command line.
|
||||
- Variables may be used inside commands (#154).
|
||||
- A `hash` function has been added for compatibiility with `sh` and `bash`
|
||||
- `while` sets `$status` to a more useful value (#4982)
|
||||
|
||||
## Other significant changes
|
||||
- Command substitution output is now limited to 10 MB by default (#3822).
|
||||
|
||||
@@ -528,6 +528,7 @@ parse_execution_result_t parse_execution_context_t::run_while_statement(
|
||||
tnode_t<g::andor_job_list> condition_boolean_tail = header.child<3>();
|
||||
|
||||
// Run while the condition is true.
|
||||
bool loop_executed = false;
|
||||
for (;;) {
|
||||
// Check the condition.
|
||||
parse_execution_result_t cond_ret =
|
||||
@@ -547,6 +548,8 @@ parse_execution_result_t parse_execution_context_t::run_while_statement(
|
||||
break;
|
||||
}
|
||||
|
||||
loop_executed = true;
|
||||
|
||||
// Push a while block and then check its cancellation reason.
|
||||
while_block_t *wb = parser->push_block<while_block_t>();
|
||||
this->run_job_list(contents, wb);
|
||||
@@ -569,6 +572,11 @@ parse_execution_result_t parse_execution_context_t::run_while_statement(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loop_executed) {
|
||||
proc_set_last_status(STATUS_CMD_OK);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user