fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

NahorFix failing system tests on Cygwin440e7fcbc

master
1.9 KiB99 linesraw
1# RUN: %fish %s
2
3# Shebangless scripts cannot be marked executable without POSIX file permissions
4# REQUIRES: %fish -c 'not cygwin_noacl $TMPDIR'
5
6# Test for shebangless scripts - see 7802.
7
8set testdir (mktemp -d)
9cd $testdir
10
11touch file
12chmod a+x file
13
14function runfile
15    # Run our file twice, printing status.
16    # Arguments are passed to exercise the re-execve code paths; they have no other effect.
17    true # clear status
18    set -g fish_use_posix_spawn 1
19    ./file arg1 arg2 arg3
20    echo $status
21
22    true # clear status
23    set -g fish_use_posix_spawn 0
24    ./file arg1 arg2 arg3 arg4 arg5
25    echo $status
26end
27
28# Empty executable files are 'true'.
29true >file
30sleep 0.1
31runfile
32#CHECK: 0
33#CHECK: 0
34
35# Files without NUL are 'true' as well.
36echo -e -n '#COMMENT\n#COMMENT' >file
37runfile
38#CHECK: 0
39#CHECK: 0
40
41# Never implicitly pass files ending with .fish to /bin/sh.
42true >file.fish
43sleep 0.1
44chmod a+x file.fish
45set -g fish_use_posix_spawn 0
46./file.fish
47#CHECKERR: exec: {{.*}}
48#CHECKERR: exec: {{.*}}
49echo $status
50#CHECK: 126
51set -g fish_use_posix_spawn 1
52./file.fish
53#CHECKERR: exec: {{.*}}
54#CHECKERR: exec: {{.*}}
55echo $status
56#CHECK: 126
57rm file.fish
58
59# On to NUL bytes.
60# The heuristic is that there must be a line containing a lowercase letter before the first NUL byte.
61echo -n -e 'true\n\x00' >file
62sleep 0.1
63runfile
64#CHECK: 0
65#CHECK: 0
66
67# Doesn't meet our heuristic as there is no newline.
68echo -n -e 'true\x00' >file
69sleep 0.1
70runfile
71#CHECK: 126
72#CHECKERR: exec: {{.*}}
73#CHECKERR: exec: {{.*}}
74
75#CHECK: 126
76#CHECKERR: exec: {{.*}}
77#CHECKERR: exec: {{.*}}
78
79# Doesn't meet our heuristic as there is no lowercase before newline.
80echo -n -e 'NOPE\n\x00' >file
81sleep 0.1
82runfile
83#CHECK: 126
84#CHECKERR: exec: {{.*}}
85#CHECKERR: exec: {{.*}}
86
87#CHECK: 126
88#CHECKERR: exec: {{.*}}
89#CHECKERR: exec: {{.*}}
90
91echo 'echo foo' >./-
92sleep 0.1
93chmod +x ./-
94set PATH ./ $PATH
95sleep 0.1
96-
97#CHECK: foo
98echo $status
99#CHECK: 0