mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 09:45:25 +08:00
Correct $status for certain pipeline-aborting failures
If we refused to launch a job because of a "pipeline aborting" error, then it's the caller's responsibility to set $status. Fixes #7540
This commit is contained in:
parent
2caeec24f7
commit
36766ea3d7
|
@ -95,6 +95,7 @@ Scripting improvements
|
|||
- An ``alias`` that delegates to a command with the same name no longer triggers an error about recursive completion (:issue:`7389`).
|
||||
- ``math`` now has a ``--base`` option to output the result in hexadecimal or octal (:issue:`7496`).
|
||||
- ``string`` subcommands now quit early when used with ``--quiet`` (:issue:`7495`).
|
||||
- Failed redirections will now set ``$status`` (:issue:`7540`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
|
|
|
@ -1391,7 +1391,13 @@ end_execution_reason_t parse_execution_context_t::run_1_job(const ast::job_t &jo
|
|||
}
|
||||
|
||||
// Actually execute the job.
|
||||
if (!exec_job(*this->parser, job, block_io)) {
|
||||
if (!exec_job(*parser, job, block_io)) {
|
||||
// No process in the job successfully launched.
|
||||
// Ensure statuses are set (#7540).
|
||||
if (auto statuses = job->get_statuses()) {
|
||||
parser->set_last_statuses(statuses.value());
|
||||
parser->libdata().status_count++;
|
||||
}
|
||||
remove_job(*this->parser, job.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -174,3 +174,31 @@ end | begin
|
|||
end
|
||||
echo $pipestatus : $status
|
||||
#CHECK: 0 0 : 0
|
||||
|
||||
# Check that failed redirections correctly handle pipestatus, etc.
|
||||
# See #7540.
|
||||
command true > /not/a/valid/path
|
||||
echo $pipestatus : $status
|
||||
#CHECK: 1 : 1
|
||||
#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
|
||||
#CHECKERR: open: No such file or directory
|
||||
|
||||
# Here the first process will launch, the second one will not.
|
||||
command true | command true | command true > /not/a/valid/path
|
||||
echo $pipestatus : $status
|
||||
#CHECK: 0 0 1 : 1
|
||||
#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
|
||||
#CHECKERR: open: No such file or directory
|
||||
|
||||
# Pipeline breaks do not result in dangling jobs.
|
||||
command true | command cat > /not/a/valid/path ; jobs
|
||||
#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
|
||||
#CHECKERR: open: No such file or directory
|
||||
#CHECK: jobs: There are no jobs
|
||||
|
||||
# Regression test for #7038
|
||||
cat /dev/zero | dd > /not/a/valid/path
|
||||
echo 'Not hung'
|
||||
#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
|
||||
#CHECKERR: open: No such file or directory
|
||||
#CHECK: Not hung
|
||||
|
|
Loading…
Reference in New Issue
Block a user