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

From: Rainer Orth <[email-masked]>
Date: Thu, 15 Apr 2021 14:14:18 +0200

Jacob Bachmeyer <[email-masked]> writes:

> 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:

Fine, thanks.

>> 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".

Upon re-checking, I seem to have misread the relevant section, sorry.
The fact remains, however, that XPG7 doesn't list that variant on

https://pubs.opengroup.org/onlinepubs/9699919799/toc.htm

which suggests (together with the behaviour of /usr/xpg6/bin/expr which
has been certified for XPG conformance AFAIK) that this usage is an
extension.