| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | export LC_ALL=C | 
					
						
							|  |  |  | export LANG=C | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-27 13:29:18 +00:00
										 |  |  | if [ $UID -eq 0 ]; then | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  |         echo "execscript: the test suite should not be run as root" >&2 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | set -- one two three | 
					
						
							| 
									
										
										
										
											1998-04-17 19:52:44 +00:00
										 |  |  | 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: $? | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # set up a fixed path so we know notthere will not be found | 
					
						
							|  |  |  | PATH=/usr/bin:/bin:/usr/local/bin: | 
					
						
							|  |  |  | export PATH | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | notthere | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # this is iffy, since the error messages may vary from system to system | 
					
						
							| 
									
										
										
										
											2004-07-27 13:29:18 +00:00
										 |  |  | # 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 | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | echo $? | 
					
						
							| 
									
										
										
										
											2004-07-27 13:29:18 +00:00
										 |  |  | rm -f /tmp/bash | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # /bin/sh should be there on all systems | 
					
						
							|  |  |  | ${THIS_SH} /bin/sh | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # try executing a directory | 
					
						
							|  |  |  | / | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ${THIS_SH} / | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # try sourcing a directory | 
					
						
							|  |  |  | . / | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2011-11-21 20:51:19 -05:00
										 |  |  | # bash-4.1 and later check for 256 NUL characters and fail as binary files | 
					
						
							|  |  |  | # if there are more than that, it's probably binary | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | . ${THIS_SH} 2>/dev/null | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | # post-bash-2.05 versions allow sourcing non-regular files | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | . /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 | 
					
						
							| 
									
										
										
										
											1998-04-17 19:52:44 +00:00
										 |  |  | ${THIS_SH} ./exec3.sub | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | rm -f /tmp/bashenv | 
					
						
							|  |  |  | unset BASH_ENV | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # we're resetting the $PATH to empty, so this should be last | 
					
						
							|  |  |  | PATH= | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | notthere | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | command notthere | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | command -p notthere | 
					
						
							|  |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # but -p should guarantee that we find all the standard utilities, even | 
					
						
							|  |  |  | # with an empty or unset $PATH | 
					
						
							|  |  |  | command -p sh -c 'echo this is $0' | 
					
						
							|  |  |  | unset PATH | 
					
						
							|  |  |  | command -p sh -c 'echo this is $0' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # a bug in bash before bash-2.01 caused PATH to be set to the empty string | 
					
						
							|  |  |  | # when command -p was run with PATH unset | 
					
						
							|  |  |  | echo ${PATH-unset} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "echo ok" | ${THIS_SH} -t | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-17 19:52:44 +00:00
										 |  |  | ${THIS_SH} ./exec2.sub | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | echo $? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-17 19:52:44 +00:00
										 |  |  | ${THIS_SH} ./exec4.sub | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # try exec'ing a command that cannot be found in $PATH | 
					
						
							|  |  |  | ${THIS_SH} ./exec5.sub | 
					
						
							| 
									
										
										
										
											2000-03-17 21:46:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # this was a bug in bash versions before bash-2.04 | 
					
						
							|  |  |  | ${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&- | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # checks for proper return values in subshell commands with inverted return | 
					
						
							|  |  |  | # values | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ${THIS_SH} ./exec6.sub | 
					
						
							| 
									
										
										
										
											2004-07-27 13:29:18 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # checks for properly deciding what constitutes an executable file | 
					
						
							|  |  |  | ${THIS_SH} ./exec7.sub | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  | ${THIS_SH} -i ./exec8.sub | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-22 19:11:26 -05:00
										 |  |  | ${THIS_SH} ./exec9.sub | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | true | `echo true` & | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo after | 
					
						
							| 
									
										
										
										
											2011-11-22 19:11:26 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Problem with bash at least back to version 3.0 | 
					
						
							|  |  |  | ${THIS_SH} -c 'VAR=0; VAR=1 command exec; exit ${VAR}' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # problem with bash through bash-4.1 | 
					
						
							|  |  |  | ( | 
					
						
							|  |  |  |         exec /var/empty/nosuch | 
					
						
							|  |  |  |         echo bad | 
					
						
							|  |  |  | ) 2>/dev/null | 
					
						
							|  |  |  | [ $? = 127 ] || echo FAIL: bad exit status $? at $LINENO |