1 | export LC_ALL=C
|
---|
2 | export LANG=C
|
---|
3 |
|
---|
4 | if [ $UID -eq 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 | # and /tmp might not exist
|
---|
25 | ln -s ${THIS_SH} /tmp/bash 2>/dev/null
|
---|
26 | if [ -f /tmp/bash ]; then
|
---|
27 | /tmp/bash notthere
|
---|
28 | else
|
---|
29 | ${THIS_SH} notthere
|
---|
30 | fi
|
---|
31 | echo $?
|
---|
32 | rm -f /tmp/bash
|
---|
33 |
|
---|
34 | # /bin/sh should be there on all systems
|
---|
35 | ${THIS_SH} /bin/sh
|
---|
36 | echo $?
|
---|
37 |
|
---|
38 | # try executing a directory
|
---|
39 | /
|
---|
40 | echo $?
|
---|
41 |
|
---|
42 | ${THIS_SH} /
|
---|
43 | echo $?
|
---|
44 |
|
---|
45 | # try sourcing a directory
|
---|
46 | . /
|
---|
47 | echo $?
|
---|
48 |
|
---|
49 | # try sourcing a binary file -- post-2.04 versions don't do the binary file
|
---|
50 | # check, and will probably fail with `command not found', or status 127
|
---|
51 | . ${THIS_SH} 2>/dev/null
|
---|
52 | echo $?
|
---|
53 |
|
---|
54 | # post-bash-2.05 versions allow sourcing non-regular files
|
---|
55 | . /dev/null
|
---|
56 | echo $?
|
---|
57 |
|
---|
58 | # kill two birds with one test -- test out the BASH_ENV code
|
---|
59 | echo echo this is bashenv > /tmp/bashenv
|
---|
60 | export BASH_ENV=/tmp/bashenv
|
---|
61 | ${THIS_SH} ./exec3.sub
|
---|
62 | rm -f /tmp/bashenv
|
---|
63 | unset BASH_ENV
|
---|
64 |
|
---|
65 | # we're resetting the $PATH to empty, so this should be last
|
---|
66 | PATH=
|
---|
67 |
|
---|
68 | notthere
|
---|
69 | echo $?
|
---|
70 |
|
---|
71 | command notthere
|
---|
72 | echo $?
|
---|
73 |
|
---|
74 | command -p notthere
|
---|
75 | echo $?
|
---|
76 |
|
---|
77 | # but -p should guarantee that we find all the standard utilities, even
|
---|
78 | # with an empty or unset $PATH
|
---|
79 | command -p sh -c 'echo this is $0'
|
---|
80 | unset PATH
|
---|
81 | command -p sh -c 'echo this is $0'
|
---|
82 |
|
---|
83 | # a bug in bash before bash-2.01 caused PATH to be set to the empty string
|
---|
84 | # when command -p was run with PATH unset
|
---|
85 | echo ${PATH-unset}
|
---|
86 |
|
---|
87 | echo "echo ok" | ${THIS_SH} -t
|
---|
88 |
|
---|
89 | ${THIS_SH} ./exec2.sub
|
---|
90 | echo $?
|
---|
91 |
|
---|
92 | ${THIS_SH} ./exec4.sub
|
---|
93 |
|
---|
94 | # try exec'ing a command that cannot be found in $PATH
|
---|
95 | ${THIS_SH} ./exec5.sub
|
---|
96 |
|
---|
97 | # this was a bug in bash versions before bash-2.04
|
---|
98 | ${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
|
---|
99 |
|
---|
100 | # checks for proper return values in subshell commands with inverted return
|
---|
101 | # values
|
---|
102 |
|
---|
103 | ${THIS_SH} ./exec6.sub
|
---|
104 |
|
---|
105 | # checks for properly deciding what constitutes an executable file
|
---|
106 | ${THIS_SH} ./exec7.sub
|
---|
107 |
|
---|
108 | true | `echo true` &
|
---|
109 |
|
---|
110 | echo after
|
---|