2024-03-30 15:10:12 +00:00
|
|
|
# RUN: %fish %s | %filter-ctrlseqs
|
2021-03-27 23:07:57 +00:00
|
|
|
|
2022-12-03 01:07:15 +00:00
|
|
|
# Do not run under sanitizers in CI, as they intercept a busted posix_spawn
|
|
|
|
# which mishandles shebangless scripts.
|
|
|
|
# REQUIRES: sh 'test -z $FISH_CI_SAN'
|
|
|
|
|
2021-03-27 23:07:57 +00:00
|
|
|
# Test for shebangless scripts - see 7802.
|
|
|
|
|
|
|
|
set testdir (mktemp -d)
|
|
|
|
cd $testdir
|
|
|
|
|
2021-05-31 20:41:49 +00:00
|
|
|
touch file
|
2021-03-27 23:07:57 +00:00
|
|
|
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.
|
2021-03-28 04:21:29 +00:00
|
|
|
true # clear status
|
|
|
|
set -g fish_use_posix_spawn 1
|
2021-03-27 23:07:57 +00:00
|
|
|
./file arg1 arg2 arg3
|
|
|
|
echo $status
|
|
|
|
|
2021-03-28 04:21:29 +00:00
|
|
|
true # clear status
|
|
|
|
set -g fish_use_posix_spawn 0
|
2021-03-27 23:07:57 +00:00
|
|
|
./file arg1 arg2 arg3 arg4 arg5
|
|
|
|
echo $status
|
|
|
|
end
|
|
|
|
|
|
|
|
# Empty executable files are 'true'.
|
2021-05-31 20:41:49 +00:00
|
|
|
true >file
|
|
|
|
sleep 0.1
|
2021-03-27 23:07:57 +00:00
|
|
|
runfile
|
|
|
|
#CHECK: 0
|
|
|
|
#CHECK: 0
|
|
|
|
|
|
|
|
# Files without NUL are 'true' as well.
|
2021-05-31 20:41:49 +00:00
|
|
|
echo -e -n '#COMMENT\n#COMMENT' >file
|
2021-03-27 23:07:57 +00:00
|
|
|
runfile
|
|
|
|
#CHECK: 0
|
|
|
|
#CHECK: 0
|
|
|
|
|
2021-03-28 02:17:18 +00:00
|
|
|
# Never implicitly pass files ending with .fish to /bin/sh.
|
2021-05-31 20:41:49 +00:00
|
|
|
true >file.fish
|
|
|
|
sleep 0.1
|
2021-03-28 02:17:18 +00:00
|
|
|
chmod a+x file.fish
|
|
|
|
set -g fish_use_posix_spawn 0
|
|
|
|
./file.fish
|
|
|
|
echo $status
|
|
|
|
set -g fish_use_posix_spawn 1
|
|
|
|
./file.fish
|
|
|
|
echo $status
|
|
|
|
rm file.fish
|
2021-03-28 04:21:29 +00:00
|
|
|
#CHECK: 126
|
2021-07-05 21:29:24 +00:00
|
|
|
#CHECKERR: exec: {{.*}}{{.*}}
|
2021-12-29 13:46:25 +00:00
|
|
|
#CHECKERR: exec: {{.*}}
|
2021-03-28 02:17:18 +00:00
|
|
|
|
2021-03-28 04:21:29 +00:00
|
|
|
#CHECK: 126
|
2021-03-28 02:17:18 +00:00
|
|
|
#CHECKERR: exec: {{.*}}
|
2021-12-29 13:46:25 +00:00
|
|
|
#CHECKERR: exec: {{.*}}
|
2021-03-28 02:17:18 +00:00
|
|
|
|
|
|
|
|
2021-03-27 23:07:57 +00:00
|
|
|
# On to NUL bytes.
|
|
|
|
# The heuristic is that there must be a line containing a lowercase letter before the first NUL byte.
|
2021-05-31 20:41:49 +00:00
|
|
|
echo -n -e 'true\n\x00' >file
|
|
|
|
sleep 0.1
|
2021-03-27 23:07:57 +00:00
|
|
|
runfile
|
|
|
|
#CHECK: 0
|
|
|
|
#CHECK: 0
|
|
|
|
|
|
|
|
# Doesn't meet our heuristic as there is no newline.
|
2021-05-31 20:41:49 +00:00
|
|
|
echo -n -e 'true\x00' >file
|
|
|
|
sleep 0.1
|
2021-03-27 23:07:57 +00:00
|
|
|
runfile
|
2021-03-28 04:21:29 +00:00
|
|
|
#CHECK: 126
|
2021-03-27 23:07:57 +00:00
|
|
|
#CHECKERR: exec: {{.*}}
|
|
|
|
|
2021-03-28 04:21:29 +00:00
|
|
|
#CHECK: 126
|
2021-03-27 23:07:57 +00:00
|
|
|
#CHECKERR: exec: {{.*}}
|
|
|
|
|
|
|
|
# Doesn't meet our heuristic as there is no lowercase before newline.
|
2021-05-31 20:41:49 +00:00
|
|
|
echo -n -e 'NOPE\n\x00' >file
|
2021-05-26 15:09:56 +00:00
|
|
|
sleep 0.1
|
2021-03-27 23:07:57 +00:00
|
|
|
runfile
|
2021-03-28 04:21:29 +00:00
|
|
|
#CHECK: 126
|
2021-03-27 23:07:57 +00:00
|
|
|
#CHECKERR: exec: {{.*}}
|
|
|
|
|
2021-03-28 04:21:29 +00:00
|
|
|
#CHECK: 126
|
2021-03-27 23:07:57 +00:00
|
|
|
#CHECKERR: exec: {{.*}}
|
2021-12-02 20:10:57 +00:00
|
|
|
|
|
|
|
echo 'echo foo' >./-
|
|
|
|
sleep 0.1
|
|
|
|
chmod +x ./-
|
|
|
|
set PATH ./ $PATH
|
|
|
|
sleep 0.1
|
|
|
|
-
|
|
|
|
#CHECK: foo
|
|
|
|
echo $status
|
|
|
|
#CHECK: 0
|