mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 03:01:11 -03:00
Clean up and relnote shebangless script support
This adds a test for shebangless support from #7802, cleans up some of its tricks, and includes it in the changelog.
This commit is contained in:
66
tests/checks/noshebang.fish
Normal file
66
tests/checks/noshebang.fish
Normal file
@@ -0,0 +1,66 @@
|
||||
# RUN: %fish %s
|
||||
|
||||
# Test for shebangless scripts - see 7802.
|
||||
|
||||
set testdir (mktemp -d)
|
||||
cd $testdir
|
||||
|
||||
touch file
|
||||
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
|
||||
./file arg1 arg2 arg3
|
||||
echo $status
|
||||
|
||||
set -g fish_use_posix_spawn 1
|
||||
./file arg1 arg2 arg3 arg4 arg5
|
||||
echo $status
|
||||
end
|
||||
|
||||
# Empty executable files are 'true'.
|
||||
true >file
|
||||
runfile
|
||||
#CHECK: 0
|
||||
#CHECK: 0
|
||||
|
||||
# Files without NUL are 'true' as well.
|
||||
echo -e -n '#COMMENT\n#COMMENT' >file
|
||||
runfile
|
||||
#CHECK: 0
|
||||
#CHECK: 0
|
||||
|
||||
# On to NUL bytes.
|
||||
# The heuristic is that there must be a line containing a lowercase letter before the first NUL byte.
|
||||
echo -n -e 'true\n\x00' >file
|
||||
runfile
|
||||
#CHECK: 0
|
||||
#CHECK: 0
|
||||
|
||||
# Doesn't meet our heuristic as there is no newline.
|
||||
echo -n -e 'true\x00' >file
|
||||
runfile
|
||||
#CHECK: 125
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
|
||||
#CHECK: 125
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
|
||||
# Doesn't meet our heuristic as there is no lowercase before newline.
|
||||
echo -n -e 'NOPE\n\x00' >file
|
||||
runfile
|
||||
#CHECK: 125
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
|
||||
#CHECK: 125
|
||||
#CHECKERR: Failed {{.*}}
|
||||
#CHECKERR: exec: {{.*}}
|
||||
#CHECKERR: {{.*}}
|
||||
Reference in New Issue
Block a user