Subject: Re: bug#47382: runtest doesn't work with Solaris 10 /bin/sh

From: Jacob Bachmeyer <[email-masked]>
Date: Wed, 14 Apr 2021 23:00:17 -0500

Rainer Orth wrote:
> [...] here's an excerpt from running
>
> env EXPECT=true TCLSH=true /bin/ksh -x /vol/gcc/obj/dejagnu/dejagnu-1.6.3-rc3/10-fresh/testsuite/launcher.all/command/bin/dejagnu foo -v -v
>
> + test -f /vol/gcc/obj/dejagnu/dejagnu-1.6.3-rc3/10-fresh/testsuite/launcher.all
> /command/share/dejagnu/commands/dejagnu.sh
> + expr foo : -
> + 1> /dev/null
> expr: syntax error
>   

Thank you!  That identifies the problem.  As of commit 
c95e2e9b567a1c3ca22b2de4fdcdfe4b99ba2a03, the dejagnu launcher script 
now uses the shell "case" builtin for that pattern match instead of 
using expr:

8<----
diff --git a/dejagnu b/dejagnu
index 44c8962..9f6ae4b 100755
--- a/dejagnu
+++ b/dejagnu
@@ -152,9 +152,7 @@ command=`basename "$0" | sed -e 's/^.*-\?dejagnu-\?//'`
 while expr $# \> 0 > /dev/null
 do
     if test -z "${command}" ; then
-       if expr "$1" : - > /dev/null ; then
-           break
-       fi
+       case $1 in -*) break;; esac
        command="$1"
        shift
     fi
@@ -167,9 +165,7 @@ do
            break 2
        fi
     done
-    if expr "$1" : - > /dev/null ; then
-       break
-    fi
+    case $1 in -*) break;; esac
     if test -n "$1" ; then
        command="${command}-$1"
        shift
8<----

> It seems this is no wonder:
>
> expr foo : -
>
> is not in XPG7/POSIX.1 and the autoconf manual explicitly states that
> this is an unportable non-POSIX extension.

Can you cite exactly where in the Autoconf manual that is mentioned?  
The closest that I can find is a recommendation to use `expr X"word" : 
'Xregex'` to handle cases where "word" starts with a dash; here Solaris 
10 is rejecting a case where "word" is "foo".

-- Jacob