Imported from ../bash-2.05a.tar.gz.
[platform/upstream/bash.git] / tests / execscript
1 export LC_ALL=C
2 export LANG=C
3
4 if (( $UID == 0 )); then
5         echo "execscript: the test suite should not be run as root" >&2
6 fi
7
8 set -- one two three
9 echo before exec1.sub: "$@"
10 echo calling exec1.sub
11 ./exec1.sub aa bb cc dd ee
12 echo after exec1.sub with args: $?
13 ./exec1.sub
14 echo after exec1.sub without args: $?
15
16 # set up a fixed path so we know notthere will not be found
17 PATH=/usr/bin:/bin:/usr/local/bin:
18 export PATH
19
20 notthere
21 echo $?
22
23 # this is iffy, since the error messages may vary from system to system
24 ${THIS_SH} notthere
25 echo $?
26
27 # /bin/sh should be there on all systems
28 ${THIS_SH} /bin/sh
29 echo $?
30
31 # try executing a directory
32 /
33 echo $?
34
35 ${THIS_SH} /
36 echo $?
37
38 # try sourcing a directory
39 . /
40 echo $?
41
42 # try sourcing a binary file -- post-2.04 versions don't do the binary file
43 # check, and will probably fail with `command not found', or status 127
44 . ${THIS_SH} 2>/dev/null
45 echo $?
46
47 # post-bash-2.05 versions allow sourcing non-regular files
48 . /dev/null
49 echo $?
50
51 # kill two birds with one test -- test out the BASH_ENV code
52 echo echo this is bashenv > /tmp/bashenv
53 export BASH_ENV=/tmp/bashenv
54 ${THIS_SH} ./exec3.sub
55 rm -f /tmp/bashenv
56 unset BASH_ENV
57
58 # we're resetting the $PATH to empty, so this should be last
59 PATH=
60
61 notthere
62 echo $?
63
64 command notthere
65 echo $?
66
67 command -p notthere
68 echo $?
69
70 # but -p should guarantee that we find all the standard utilities, even
71 # with an empty or unset $PATH
72 command -p sh -c 'echo this is $0'
73 unset PATH
74 command -p sh -c 'echo this is $0'
75
76 # a bug in bash before bash-2.01 caused PATH to be set to the empty string
77 # when command -p was run with PATH unset
78 echo ${PATH-unset}
79
80 echo "echo ok" | ${THIS_SH} -t
81
82 ${THIS_SH} ./exec2.sub
83 echo $?
84
85 ${THIS_SH} ./exec4.sub
86
87 # try exec'ing a command that cannot be found in $PATH
88 ${THIS_SH} ./exec5.sub
89
90 # this was a bug in bash versions before bash-2.04
91 ${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
92
93 # checks for proper return values in subshell commands with inverted return
94 # values
95
96 ${THIS_SH} ./exec6.sub