diff options
author | Jacob Bachmeyer <jcb@gnu.org> | 2021-03-25 23:35:53 -0500 |
---|---|---|
committer | Jacob Bachmeyer <jcb@gnu.org> | 2021-03-25 23:35:53 -0500 |
commit | e3b14d8555c5cabad03b9ccaa6aa1976ed590201 (patch) | |
tree | daaae93a7692cec562740ea6163f78212a01ee07 | |
parent | dcf155087a1311d9d90da3c12ce81935b3f926cc (diff) | |
download | dejagnu-e3b14d8555c5cabad03b9ccaa6aa1976ed590201.zip dejagnu-e3b14d8555c5cabad03b9ccaa6aa1976ed590201.tar.gz dejagnu-e3b14d8555c5cabad03b9ccaa6aa1976ed590201.tar.bz2 |
Use older shell constructs to fix PR47382
The Solaris 10 /bin/sh does not support POSIX command or arithmetic
substitutions. This commit reverts to using the old style backtick
form and the expr command for arithmetic.
-rw-r--r-- | ChangeLog | 17 | ||||
-rwxr-xr-x | dejagnu | 39 | ||||
-rwxr-xr-x | runtest | 32 |
3 files changed, 67 insertions, 21 deletions
@@ -1,3 +1,20 @@ +2021-03-25 Jacob Bachmeyer <jcb@gnu.org> + + PR47382 + + * dejagnu, runtest: Remove use of "$()" command substitution and + "$(())" arithmetic substitution shell constructs. The /bin/sh on + Solaris 10 does not support them. They were replaced with the + traditional backticks for command substitution and backticks and + the expr command for arithmetic substitution. + + Also add markers to explicitly disable shellcheck warnings that + would lead to reintroducing these problems. + + Also avoid the non-portable "`..."..."...`" construct on a warning + in the GNU Autoconf manual, section "Shell Substitutions", + although this introduces additional variables. + 2021-03-22 Jacob Bachmeyer <jcb@gnu.org> * configure: Regenerate. @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2018 Free Software Foundation, Inc. +# Copyright (C) 2018, 2021 Free Software Foundation, Inc. # # This file is part of DejaGnu. # @@ -28,6 +28,18 @@ # either be run with a command name as the first (few) argument(s), via a # link from the command name, or some combination of those. +# shellcheck disable=SC2003 +# The shellcheck tool complains about use of expr and recommends using +# newer shell features instead. Solaris 10 /bin/sh does not support the +# newer features, so we must use expr in this script. + +# shellcheck disable=SC2006 +# The shellcheck tool complains about the old style backtick command +# substitution. Solaris 10 /bin/sh does not support the new style $() +# command substitution and the usage of command substitution in this script +# is simple enough to work. Most notably, nesting backtick command +# substitution is tricky, but we do not do that. + # shellcheck disable=SC2209 # The shellcheck tool complains about assigning certain constant strings to # variables. In this script, the intended meaning is obvious in context. @@ -57,19 +69,19 @@ want_version=false verbose=0 for a in "$@"; do case $a in - --help) want_help=true ;; - -v|--v|-verbose|--verbose) verbose=$((verbose + 1)) ;; - -V|--V|-version|--version) want_version=true ;; + --help) want_help=true ;; + -v|--v|-verbose|--verbose) verbose=`expr $verbose + 1` ;; + -V|--V|-version|--version) want_version=true ;; esac done if expr "$verbose" \> 0 > /dev/null ; then - echo Verbose level is $verbose + echo Verbose level is "$verbose" fi ## Get the file name of this script and deduce @bindir@. -bindir="$(echo "$0" | sed -e 's@/[^/]*$@@')" +bindir=`echo "$0" | sed -e 's@/[^/]*$@@'` if expr "$verbose" \> 0 > /dev/null ; then echo Running launcher from "$bindir" fi @@ -97,9 +109,10 @@ elif test -d "${bindir}/commands" && test -f "${bindir}/runtest.exp" ; then datadir="${bindir}" else commdir= + bindir1up_check=`echo "$bindir" | sed -e 's@/[^/]*$@/share/dejagnu@'` + bindir2up_check=`echo "$bindir" | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@'` for i in \ - "$(echo "$bindir" | sed -e 's@/[^/]*$@/share/dejagnu@')" \ - "$(echo "$bindir" | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@')" \ + "${bindir1up_check}" "${bindir2up_check}" \ /usr/share/dejagnu /usr/local/share/dejagnu do if expr "$verbose" \> 1 > /dev/null ; then @@ -126,14 +139,14 @@ fi # Are we just looking for version information? if $want_version ; then - frame_version=$(grep '^set frame_version' "${datadir}/runtest.exp" \ - | sed 's/^[^0-9]*//') + frame_version=`grep '^set frame_version' "${datadir}/runtest.exp" \ + | sed 's/^[^0-9]*//'` echo 'dejagnu auxiliary launcher (DejaGnu)' "$frame_version" exit 0 fi # Remove any leading autoconf platform prefix and the "dejagnu" prefix. -command="$(basename "$0" | sed -e 's/^.*-\?dejagnu-\?//')" +command=`basename "$0" | sed -e 's/^.*-\?dejagnu-\?//'` while expr $# \> 0 > /dev/null do @@ -401,8 +414,8 @@ if $want_help ; then echo ERROR: file "'$help_file'" does not contain a help message exit 2 fi - help_prefix_pat=$(grep '#help' "$help_file" \ - | sed -e 's/#help.*$//' -e '1q' | tr '[:print:][:blank:]' .) + help_prefix_pat=`grep '#help' "$help_file" \ + | sed -e 's/#help.*$//' -e '1q' | tr '[:print:][:blank:]' .` if expr "$verbose" \> 1 > /dev/null ; then echo Extracting help from "'$help_file'" with prefix "'$help_prefix_pat'" fi @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 1992-2016 Free Software Foundation, Inc. +# Copyright (C) 1992-2016, 2021 Free Software Foundation, Inc. # # This file is part of DejaGnu. # @@ -21,6 +21,18 @@ # This script was written by Rob Savoye. The script finds the proper # expect shell and then starts DejaGnu. +# shellcheck disable=SC2003 +# The shellcheck tool complains about use of expr and recommends using +# newer shell features instead. Solaris 10 /bin/sh does not support the +# newer features, so we must use expr in this script. + +# shellcheck disable=SC2006 +# The shellcheck tool complains about the old style backtick command +# substitution. Solaris 10 /bin/sh does not support the new style $() +# command substitution and the usage of command substitution in this script +# is simple enough to work. Most notably, nesting backtick command +# substitution is tricky, but we do not do that. + # Get the execution path to this script and the current directory. mypath=${0-.} @@ -40,13 +52,13 @@ else done IFS="$save_ifs" fi -execpath=$(echo "$mypath" | sed -e 's@/[^/]*$@@') +execpath=`echo "$mypath" | sed -e 's@/[^/]*$@@'` # Get the name by which runtest was invoked and extract the config # triplet. -runtest=$(echo "$mypath" | sed -e 's@^.*/@@') -target=$(echo "$runtest" | sed -e 's/-runtest$//') +runtest=`echo "$mypath" | sed -e 's@^.*/@@'` +target=`echo "$runtest" | sed -e 's/-runtest$//'` if [ "$target" != runtest ] ; then target="--target ${target}" else @@ -86,7 +98,7 @@ verbose=0 debug="" for a in "$@" ; do case $a in - -v|--v|-verb*|--verb*) verbose=$((verbose + 1)) ;; + -v|--v|-verb*|--verb*) verbose=`expr $verbose + 1` ;; -D0|--D0) debug="-D 0" ;; -D1|--D1) debug="-D 1" ;; esac @@ -108,10 +120,11 @@ fi # # .. which is a very weak assumption +bindir1up_check=`echo "$execpath" | sed -e 's@/[^/]*$@/share/dejagnu@'` +bindir2up_check=`echo "$execpath" | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@'` + for i in \ - $(echo "$execpath" | sed -e 's@/[^/]*$@/share/dejagnu@') \ - $(echo "$execpath" | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@') \ - "$execpath" \ + "${bindir1up_check}" "${bindir2up_check}" "$execpath" \ /usr/share/dejagnu \ /usr/local/share/dejagnu ; do if expr "$verbose" \> 1 > /dev/null ; then @@ -144,4 +157,7 @@ if ! command -v "$expectbin" > /dev/null ; then exit 1 fi +# The `debug' and `target' variables are _intended_ to contain zero or two +# words each. Word splitting is desired here. +# shellcheck disable=SC2086 exec "$expectbin" $debug -- "$runpath"/runtest.exp $target ${1+"$@"} |