[Rd] Dialect for shell scripts
Kurt.Hornik at wu.ac.at
Mon Dec 18 20:23:58 CET 2017
>>>>> Iñaki Úcar writes:
Same from here: in addition to what the standards say, it always pays to
be defensive and check "Portable Shell Programming" in the Autoconf
manual. Among other things, this says
Arithmetic expansion is not portable as some shells (most notably
Solaris 10 '/bin/sh') don't support it.
motivating the code shown below. Perhaps simplest to always use expr.
> For what it's worth, Autoconf does not assume that arithmetic
> expansion will be available. Instead, it emits the following shell
> if ( eval 'test $(( 1 + 1 )) = 2' ) 2>/dev/null; then
> eval 'func_arith ()
> func_arith_result=$(( $* ))
> func_arith ()
> func_arith_result=`expr "$@"`
> 2017-12-17 23:55 GMT+01:00 Rodrigo Tobar <rtobar at icrar.org>:
>> Dear all,
>> During a recent package submission, we were highlighted that some lines in
>> our configure script didn't follow the correct syntax. The lines looked like
>> We were indicated at the time that this is because the statement does not
>> use Bourne shell syntax, which is absolutely true, and also that the manual
>> warns about this, which is true again. So far everything is clear.
>> However, what confuses me is that even when the manual says that "you can
>> include an executable (Bourne) shell script configure in your package" ,
>> the associated footnote says something slightly different: "The script
>> should only assume a POSIX-compliant /bin/sh" . The footnote goes even
>> further, and links to the POSIX specification of the Shell Command Language
>>  (as published by The Open Group), which explicitly includes arithmetic
>> expressions like the one above in its syntax .
>> My question then is: what exact dialect should be considered? Given that the
>> statement above does not work in the Bourne shell, I conclude that the
>> Bourne shell is not POSIX-compliant. That in turn would make the manual
>> ambiguous as to the precise dialect that should be used by our configure
>> scripts, and either the shells used by R should be changed to be
>> POSIX-compliants, or the manual edited to be more precise regarding .
>> Many thanks.
>>  https://cran.r-project.org/doc/manuals/r-release/R-exts.html#FOOT25
>>  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
>> R-devel at r-project.org mailing list
> Iñaki Úcar
> R-devel at r-project.org mailing list
More information about the R-devel