mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 01:17:45 +00:00
Fix status when function/block evaluation is cancelled
It looks like the last status already contains the signal that cancelled execution. Also make `fish -c something` always return the last exit status of "something", instead of hardcoded 127 if exited or signalled. Fixes #6444
This commit is contained in:
parent
8ca936aea6
commit
9f48fc6285
3 changed files with 17 additions and 12 deletions
|
@ -737,10 +737,8 @@ static proc_performer_t get_performer_for_process(process_t *p, const job_t *job
|
|||
switch (res) {
|
||||
case eval_result_t::ok:
|
||||
case eval_result_t::error:
|
||||
return proc_status_t::from_exit_code(parser.get_last_status());
|
||||
case eval_result_t::cancelled:
|
||||
// TODO: we should reflect the actual signal which was received.
|
||||
return proc_status_t::from_signal(SIGINT);
|
||||
return proc_status_t::from_exit_code(parser.get_last_status());
|
||||
case eval_result_t::control_flow:
|
||||
default:
|
||||
DIE("eval_result_t::control_flow should not be returned from eval_node");
|
||||
|
@ -768,11 +766,8 @@ static proc_performer_t get_performer_for_process(process_t *p, const job_t *job
|
|||
? EXIT_SUCCESS
|
||||
: parser.get_last_status());
|
||||
case eval_result_t::error:
|
||||
return proc_status_t::from_exit_code(parser.get_last_status());
|
||||
|
||||
case eval_result_t::cancelled:
|
||||
// TODO: we should reflect the actual signal which was received.
|
||||
return proc_status_t::from_signal(SIGINT);
|
||||
return proc_status_t::from_exit_code(parser.get_last_status());
|
||||
default:
|
||||
case eval_result_t::control_flow:
|
||||
DIE("eval_result_t::control_flow should not be returned from eval_node");
|
||||
|
|
|
@ -249,16 +249,14 @@ static int read_init(const struct config_paths_t &paths) {
|
|||
}
|
||||
|
||||
int run_command_list(std::vector<std::string> *cmds, const io_chain_t &io) {
|
||||
int res = 1;
|
||||
parser_t &parser = parser_t::principal_parser();
|
||||
|
||||
for (const auto &cmd : *cmds) {
|
||||
const wcstring cmd_wcs = str2wcstring(cmd);
|
||||
eval_result_t eval_res = parser.eval(cmd_wcs, io);
|
||||
res = (eval_res == eval_result_t::ok ? 0 : 1);
|
||||
parser.eval(cmd_wcs, io);
|
||||
}
|
||||
|
||||
return res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Parse the argument list, return the index of the first non-flag arguments.
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
# RUN: %fish %s
|
||||
# RUN: %fish -C 'set -l fish %fish' %s
|
||||
|
||||
$fish -c 'function main; exit 4; true; end; main'; echo $status
|
||||
#CHECK: 4
|
||||
|
||||
$fish -c 'begin; exit 5; true; end'; echo $status
|
||||
#CHECK: 5
|
||||
|
||||
$fish -c 'kill -SIGHUP %self'; echo $status
|
||||
#CHECK: 129
|
||||
|
||||
$fish -c 'function main; kill -SIGTERM %self; true; end; main'; echo $status
|
||||
#CHECK: 143
|
||||
|
||||
function alarm --on-signal ALRM
|
||||
echo ALRM received
|
||||
|
|
Loading…
Reference in a new issue