diff options
author | Jacob Bachmeyer <jcb@gnu.org> | 2021-05-19 00:19:20 -0500 |
---|---|---|
committer | Jacob Bachmeyer <jcb@gnu.org> | 2021-05-19 00:19:20 -0500 |
commit | 9673505b54f1f2017f4dae7a2b972503e687f04c (patch) | |
tree | f38599d620fe03f2bb719fed453cf91d921a0d0c | |
parent | 0bab163959ff64d788bbdbd1c8719c44c9d4c95a (diff) | |
download | dejagnu-9673505b54f1f2017f4dae7a2b972503e687f04c.zip dejagnu-9673505b54f1f2017f4dae7a2b972503e687f04c.tar.gz dejagnu-9673505b54f1f2017f4dae7a2b972503e687f04c.tar.bz2 |
Replace non-portable Awk code in dejagnu auxiliary launcher
-rw-r--r-- | ChangeLog | 2 | ||||
-rwxr-xr-x | dejagnu | 28 |
2 files changed, 17 insertions, 13 deletions
@@ -3,6 +3,8 @@ * dejagnu: Redirect input from /dev/null when testing if awk is GNU Awk; this avoids a hang on Solaris 10 where awk treats --version as an Awk program and attempts to read input. + (command): Rework the initial setting of this variable to avoid + limitations in Solaris 10 awk. * testsuite/report-card.all/onetest.exp: Avoid Tcl error when item and totals lines are missing entirely. @@ -148,19 +148,21 @@ fi # Remove any leading autoconf platform prefix and the "dejagnu" prefix. # command=`basename "$0" | sed -e 's/^.*-\?dejagnu-\?//'` -# The above simple solution is not portable, so we use Awk: -command=`echo "$0" | awk 'BEGIN { FS = "/" } -{ OFS = FS = "-" - $0 = $NF - for (i = 1; i <= NF; i++) if ($i ~ /dejagnu/) break; - for (j = 1; j <= (NF - i); j++) $j = $(j+i); - NF = j - 1 - print }'` -# Initially splitting on "/", then assigning the last field to the record -# performs the role of basename. Splitting on "-" and searching for a -# field matching /dejagnu/ identifies the other prefixes, and the second -# loop removes the "dejagnu" prefix and everything before it. The record -# is then truncated, printed, and thereby returned to the shell. + +# The above simple solution is not portable, so we use Awk and two steps: +command=`echo "$0" | awk 'BEGIN { FS = "/" } { print $NF }'` +# First, we use a simple Awk program to perform the role of basename. +command=`echo "$command" | awk 'BEGIN { OFS = FS = "-" } + { for (i = 1; i <= NF; i++) if ($i ~ /dejagnu/) break; + i++; for (out = ""; i <= NF; i++) out = out OFS $i; + print substr(out,2) }'` +# Second, we split on "-" and search for a field matching /dejagnu/ to +# identify the other prefixes, then skip that field and the second loop +# collects any following fields. The spurious leading "-" is then removed +# using substr() and the result is returned to the shell. + +# This roundabout approach maintains compatibility with Solaris 10, where +# awk allows only limited manipulation of the record structure. while expr $# \> 0 > /dev/null do |