mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 06:41:14 -03:00
Rationalize exit codes for failed execs
This cleans up some exit code processing. Previously a failed exec would produce exit code 125 unconditionally, while a failed posix_spawn would produce exit code 1 (!). With this change, fish reports exit code 126 for not-executable, and 127 for file-not-found. This matches bash.
This commit is contained in:
@@ -11,11 +11,13 @@ chmod a+x file
|
||||
function runfile
|
||||
# Run our file twice, printing status.
|
||||
# Arguments are passed to exercise the re-execve code paths; they have no other effect.
|
||||
set -g fish_use_posix_spawn 0
|
||||
true # clear status
|
||||
set -g fish_use_posix_spawn 1
|
||||
./file arg1 arg2 arg3
|
||||
echo $status
|
||||
|
||||
set -g fish_use_posix_spawn 1
|
||||
true # clear status
|
||||
set -g fish_use_posix_spawn 0
|
||||
./file arg1 arg2 arg3 arg4 arg5
|
||||
echo $status
|
||||
end
|
||||
@@ -42,12 +44,12 @@ set -g fish_use_posix_spawn 1
|
||||
./file.fish
|
||||
echo $status
|
||||
rm file.fish
|
||||
#CHECK: 125
|
||||
#CHECK: 126
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
|
||||
#CHECK: 125
|
||||
#CHECK: 126
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
@@ -63,12 +65,12 @@ runfile
|
||||
# Doesn't meet our heuristic as there is no newline.
|
||||
echo -n -e 'true\x00' >file
|
||||
runfile
|
||||
#CHECK: 125
|
||||
#CHECK: 126
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
|
||||
#CHECK: 125
|
||||
#CHECK: 126
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
@@ -76,12 +78,12 @@ runfile
|
||||
# Doesn't meet our heuristic as there is no lowercase before newline.
|
||||
echo -n -e 'NOPE\n\x00' >file
|
||||
runfile
|
||||
#CHECK: 125
|
||||
#CHECK: 126
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
|
||||
#CHECK: 125
|
||||
#CHECK: 126
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
|
||||
Reference in New Issue
Block a user