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  <r...@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

Reply via email to