Imported from ../bash-3.1.tar.gz.
[platform/upstream/bash.git] / tests / execscript
index 49c4c33..09a4ba5 100644 (file)
@@ -1,13 +1,17 @@
 export LC_ALL=C
 export LANG=C
 
+if [ $UID -eq 0 ]; then
+        echo "execscript: the test suite should not be run as root" >&2
+fi
+
 set -- one two three
-echo before execscript.sub: "$@"
-echo calling execscript.sub
-./execscript.sub aa bb cc dd ee
-echo after execscript.sub with args: $?
-./execscript.sub
-echo after execscript.sub without args: $?
+echo before exec1.sub: "$@"
+echo calling exec1.sub
+./exec1.sub aa bb cc dd ee
+echo after exec1.sub with args: $?
+./exec1.sub
+echo after exec1.sub without args: $?
 
 # set up a fixed path so we know notthere will not be found
 PATH=/usr/bin:/bin:/usr/local/bin:
@@ -17,8 +21,15 @@ notthere
 echo $?
 
 # this is iffy, since the error messages may vary from system to system
-${THIS_SH} notthere
+# and /tmp might not exist
+ln -s ${THIS_SH} /tmp/bash 2>/dev/null
+if [ -f /tmp/bash ]; then
+       /tmp/bash notthere
+else
+       ${THIS_SH} notthere
+fi
 echo $?
+rm -f /tmp/bash
 
 # /bin/sh should be there on all systems
 ${THIS_SH} /bin/sh
@@ -35,16 +46,19 @@ echo $?
 . /
 echo $?
 
+# try sourcing a binary file -- post-2.04 versions don't do the binary file
+# check, and will probably fail with `command not found', or status 127
 . ${THIS_SH} 2>/dev/null
 echo $?
 
+# post-bash-2.05 versions allow sourcing non-regular files
 . /dev/null
 echo $?
 
 # kill two birds with one test -- test out the BASH_ENV code
 echo echo this is bashenv > /tmp/bashenv
 export BASH_ENV=/tmp/bashenv
-${THIS_SH} ./execscript.sub3
+${THIS_SH} ./exec3.sub
 rm -f /tmp/bashenv
 unset BASH_ENV
 
@@ -72,7 +86,25 @@ echo ${PATH-unset}
 
 echo "echo ok" | ${THIS_SH} -t
 
-${THIS_SH} ./execscript.sub2
+${THIS_SH} ./exec2.sub
 echo $?
 
-${THIS_SH} ./execscript.sub4
+${THIS_SH} ./exec4.sub
+
+# try exec'ing a command that cannot be found in $PATH
+${THIS_SH} ./exec5.sub
+
+# this was a bug in bash versions before bash-2.04
+${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
+
+# checks for proper return values in subshell commands with inverted return
+# values
+
+${THIS_SH} ./exec6.sub
+
+# checks for properly deciding what constitutes an executable file
+${THIS_SH} ./exec7.sub
+
+true | `echo true` &
+
+echo after