mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 05:02:46 +08:00
src/exec: fix assertion on failed exec redirection
Minimal reproducer: `fish -c "exec cat<x"`
This commit is contained in:
parent
b247c8d9ad
commit
6e9250425a
|
@ -970,7 +970,11 @@ bool exec_job(parser_t &parser, shared_ptr<job_t> j) {
|
|||
|
||||
if (j->processes.front()->type == INTERNAL_EXEC) {
|
||||
internal_exec(parser.vars(), j.get(), all_ios);
|
||||
DIE("this should be unreachable");
|
||||
// internal_exec only returns if it failed to set up redirections.
|
||||
// In case of an successful exec, this code is not reached.
|
||||
bool status = j->get_flag(job_flag_t::NEGATE) ? 0 : 1;
|
||||
proc_set_last_status(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
// This loop loops over every process_t in the job, starting it as appropriate. This turns out
|
||||
|
|
4
tests/test_exec_fail.err
Normal file
4
tests/test_exec_fail.err
Normal file
|
@ -0,0 +1,4 @@
|
|||
<W> fish: An error occurred while redirecting file 'nosuchfile'
|
||||
open: No such file or directory
|
||||
<W> fish: An error occurred while redirecting file 'nosuchfile'
|
||||
open: No such file or directory
|
6
tests/test_exec_fail.in
Normal file
6
tests/test_exec_fail.in
Normal file
|
@ -0,0 +1,6 @@
|
|||
exec cat < nosuchfile
|
||||
echo "failed: $status"
|
||||
not exec cat < nosuchfile
|
||||
echo "neg failed: $status"
|
||||
exec cat < /dev/null
|
||||
echo "not reached"
|
2
tests/test_exec_fail.out
Normal file
2
tests/test_exec_fail.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
failed: 1
|
||||
neg failed: 0
|
1
tests/test_exec_fail.status
Normal file
1
tests/test_exec_fail.status
Normal file
|
@ -0,0 +1 @@
|
|||
0
|
Loading…
Reference in New Issue
Block a user