This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[testsuite, ada] Fix run_acats for shells without type -p


My last run_acats patch broke platforms where CONFIG_SHELL doesn't
support type -p (like Solaris < 11 /bin/ksh): when using awk to extract
the last output field, the exit code is from the last command in the
pipe (always 0), not type, so the which function returns an empty
string.

This patch fixes this by decoupling type/type -p from extracting the
last field.

Bootstrapped on i386-pc-solaris2.10 and i386-pc-solaris2.11.

Ok for mainline, 4.6 and 4.5 branches (where the offending patch has
been installed)?

Thanks.
        Rainer


2011-07-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* ada/acats/run_acats (which): Extract last field from type -p,
	type output only if command succeeded.

diff --git a/gcc/testsuite/ada/acats/run_acats b/gcc/testsuite/ada/acats/run_acats
--- a/gcc/testsuite/ada/acats/run_acats
+++ b/gcc/testsuite/ada/acats/run_acats
@@ -14,8 +14,8 @@ fi
 # Fall back to whence which ksh88 and ksh93 provide, but bash does not.
 
 which () {
-    path=`type -p $* 2>/dev/null | awk '{print $NF}'` && { echo $path; return 0; }
-    path=`type $* 2>/dev/null | awk '{print $NF}'` && { echo $path; return 0; }
+    path=`type -p $* 2>/dev/null` && { echo $path | awk '{print $NF}'; return 0; }
+    path=`type $* 2>/dev/null` && { echo $path | awk '{print $NF}'; return 0; }
     path=`whence $* 2>/dev/null` && { echo $path; return 0; }
     return 1
 }


-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


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