diff mbox

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

Message ID ydd7h7xnc08.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth July 4, 2011, 6:20 p.m. UTC
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.

Comments

Arnaud Charlet July 4, 2011, 6:45 p.m. UTC | #1
> 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)?

OK, but if this new patch introduces new regressions, please revert this
change and the previous one, thanks.

Arno
Rainer Orth July 4, 2011, 6:47 p.m. UTC | #2
Arnaud Charlet <charlet@adacore.com> writes:

>> 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)?
>
> OK, but if this new patch introduces new regressions, please revert this
> change and the previous one, thanks.

I will.  The fragility of this stuff suggests that I should revisit and
finish my ACATS via DejaGnu patch ;-)

Thanks.
        Rainer
diff mbox

Patch

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
 }