]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/execscript
bash-4.4 beta release
[thirdparty/bash.git] / tests / execscript
CommitLineData
d166f048
JA
1export LC_ALL=C
2export LANG=C
3
d3a24ed2 4if [ $UID -eq 0 ]; then
f73dda09
JA
5 echo "execscript: the test suite should not be run as root" >&2
6fi
7
d166f048 8set -- one two three
cce855bc
JA
9echo before exec1.sub: "$@"
10echo calling exec1.sub
11./exec1.sub aa bb cc dd ee
12echo after exec1.sub with args: $?
13./exec1.sub
14echo after exec1.sub without args: $?
c7e43312 15echo after exec1.sub: "$@"
d166f048
JA
16
17# set up a fixed path so we know notthere will not be found
18PATH=/usr/bin:/bin:/usr/local/bin:
19export PATH
20
21notthere
22echo $?
23
24# this is iffy, since the error messages may vary from system to system
12d937f9
CR
25# and /tmp might not exist
26ln -s ${THIS_SH} /tmp/bash 2>/dev/null
27if [ -f /tmp/bash ]; then
28 /tmp/bash notthere
29else
30 ${THIS_SH} notthere
31fi
d166f048 32echo $?
12d937f9 33rm -f /tmp/bash
d166f048
JA
34
35# /bin/sh should be there on all systems
36${THIS_SH} /bin/sh
37echo $?
38
39# try executing a directory
40/
41echo $?
42
43${THIS_SH} /
44echo $?
45
46# try sourcing a directory
47. /
48echo $?
49
28ef6c31
JA
50# try sourcing a binary file -- post-2.04 versions don't do the binary file
51# check, and will probably fail with `command not found', or status 127
b06e584e
CR
52# bash-4.1 and later check for 256 NUL characters and fail as binary files
53# if there are more than that, it's probably binary
d166f048
JA
54. ${THIS_SH} 2>/dev/null
55echo $?
56
f73dda09 57# post-bash-2.05 versions allow sourcing non-regular files
d166f048
JA
58. /dev/null
59echo $?
60
61# kill two birds with one test -- test out the BASH_ENV code
62echo echo this is bashenv > /tmp/bashenv
63export BASH_ENV=/tmp/bashenv
cce855bc 64${THIS_SH} ./exec3.sub
d166f048
JA
65rm -f /tmp/bashenv
66unset BASH_ENV
67
68# we're resetting the $PATH to empty, so this should be last
69PATH=
70
71notthere
72echo $?
73
74command notthere
75echo $?
76
77command -p notthere
78echo $?
79
80# but -p should guarantee that we find all the standard utilities, even
81# with an empty or unset $PATH
82command -p sh -c 'echo this is $0'
83unset PATH
84command -p sh -c 'echo this is $0'
85
86# a bug in bash before bash-2.01 caused PATH to be set to the empty string
87# when command -p was run with PATH unset
88echo ${PATH-unset}
89
90echo "echo ok" | ${THIS_SH} -t
91
cce855bc 92${THIS_SH} ./exec2.sub
d166f048
JA
93echo $?
94
cce855bc
JA
95${THIS_SH} ./exec4.sub
96
97# try exec'ing a command that cannot be found in $PATH
98${THIS_SH} ./exec5.sub
bb70624e
JA
99
100# this was a bug in bash versions before bash-2.04
101${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
28ef6c31
JA
102
103# checks for proper return values in subshell commands with inverted return
104# values
105
106${THIS_SH} ./exec6.sub
d3a24ed2
CR
107
108# checks for properly deciding what constitutes an executable file
109${THIS_SH} ./exec7.sub
d90269dd 110
b0c16657
CR
111${THIS_SH} -i ./exec8.sub
112
54a1fa7c
CR
113${THIS_SH} ./exec9.sub
114
1573ba78 115${THIS_SH} ./exec10.sub
bd6a350e 116${THIS_SH} ./exec11.sub
1573ba78 117
d90269dd
CR
118true | `echo true` &
119
120echo after
048b249e
CR
121
122# Problem with bash at least back to version 3.0
123${THIS_SH} -c 'VAR=0; VAR=1 command exec; exit ${VAR}'
e05be32d
CR
124
125# problem with bash through bash-4.1
126(
127 exec /var/empty/nosuch
128 echo bad
129) 2>/dev/null
130[ $? = 127 ] || echo FAIL: bad exit status $? at $LINENO
54a5fbe1
CR
131
132unset FALSE
133if [ -x /bin/false ]; then
134 FALSE=/bin/false
135elif [ -x /usr/bin/false ]; then
136 FALSE=/usr/bin/false
137else
138 FALSE='command false'
139fi
140
141# problem with undoing redirections before running exit trap through bash-4.3
142
143${THIS_SH} ./exec12.sub false # function
144${THIS_SH} ./exec12.sub command false
145${THIS_SH} ./exec12.sub $FALSE
146
147${THIS_SH} ./exec12.sub notfound
148${THIS_SH} ./exec12.sub syntaxerror
149${THIS_SH} ./exec12.sub nosuchcommand
150
151# problem with fork optimization in bash-4.4-alpha
152
153$THIS_SH -c 'echo a && /bin/echo b && echo c'
154$THIS_SH -c 'echo A && /bin/echo B'
155
156$THIS_SH -c '/bin/echo c && echo d'
157$THIS_SH -c '/bin/echo c && /bin/echo d && echo e'