This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dejagnu runtest and runtest.exp


> 
> On many systems, if a shell script is invoked because it is found on
> PATH, $0 is set with the PATH element prepended to the script name.

Well, for me this is not true with ksh on AIX or on sysV68.  Perhaps, as
Manfred Hollstein suggested does this work only with bash.

> Evidently that is not true on your system.
> 
> I think that if runtest finds that $0 is just "runtest", it should
> look through PATH looking for itself.
> 

Here is a possible patch to do that :

Mon Oct 13 19:15:41 1997  Philippe De Muyter  <phdm@macqel.be>

	* runtest (mypath): Use `type' to set mypath if $0 does not give it.

--- ./dejagnu/runtest   Mon Oct 13 19:11:47 1997
+++ ./dejagnu/runtest	Mon Oct 13 17:15:48 1997
@@ -7,13 +7,26 @@
 #
 # Get the execution path to this script and the current directory.
 #
-execpath=`echo ${0-.} | sed  -e 's@/[^/]*$@@'`
+mypath=${0-.}
+if expr ${mypath} : '.*/.*' > /dev/null
+then
+	:
+else
+	# I don't know if `type' is very portable, but it must only work
+	# for shells that do not set $0 to the full path of this script
+	# The hard way would be to parse $PATH and use test -x $path/$mypath
+	mypath=`type "$mypath"`
+	# The following extracts the full pathname from
+	# "xxx is .* /full/path/to/xxx" or "xxx is .* (/full/path/to/xxx)"
+	mypath=`expr "$mypath" : '.* (*\(.*[^)]\))*'`
+fi
+execpath=`echo ${mypath} | sed  -e 's@/[^/]*$@@'`
 # rootme=`pwd`
 
 #
 # get the name by which runtest was invoked and extract the config triplet
 #
-runtest=`echo ${0-.} | sed -e 's@^.*/@@'`
+runtest=`echo ${mypath} | sed -e 's@^.*/@@'`
 target=`echo $runtest | sed -e 's/-runtest$//'`
 if [ "$target" != runtest ] ; then
     target="--target ${target}"



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]