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

login
register
mail settings
Submitter Rainer Orth
Date July 4, 2011, 6:20 p.m.
Message ID <ydd7h7xnc08.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/103152/
State New
Headers show

Comments

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

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
 }