From: Bruno Haible Date: Thu, 17 Sep 2020 23:17:38 +0000 (+0200) Subject: doc: Mention two more shell portability problems. X-Git-Tag: v2.69c~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1f55d8f0a72175ba7eecc3e132b618958b13a2f;p=thirdparty%2Fautoconf.git doc: Mention two more shell portability problems. * doc/autoconf.texi (File Descriptors): Mention a problem of Solaris 10. Mention that a known problem also occurs in dash. --- diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 4bd6e9e7..38646a16 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -15656,6 +15656,18 @@ $ @kbd{dash -c ': 1<>file'; cat file} $ rm a @end example +Solaris 10 @code{/bin/sh} executes redirected compound commands +in a subshell, while other shells don't: + +@example +$ @kbd{/bin/sh -c 'foo=0; @{ foo=1; @} 2>/dev/null; echo $foo'} +0 +$ @kbd{ksh -c 'foo=0; @{ foo=1; @} 2>/dev/null; echo $foo'} +1 +$ @kbd{bash -c 'foo=0; @{ foo=1; @} 2>/dev/null; echo $foo'} +1 +@end example + When catering to old systems, don't redirect the same file descriptor several times, as you are doomed to failure under Ultrix. @@ -15756,8 +15768,8 @@ obsolete, so it's now safe to treat file descriptors 3 and 4 like any other file descriptors. On the other hand, you can't portably use multi-digit file descriptors. -Solaris @command{ksh} doesn't understand any file descriptor larger than -@samp{9}: +@command{dash} and Solaris @command{ksh} don't understand any file +descriptor larger than @samp{9}: @example $ @kbd{bash -c 'exec 10>&-'; echo $?} @@ -15767,6 +15779,11 @@ $ @kbd{ksh -c 'exec 9>&-'; echo $?} $ @kbd{ksh -c 'exec 10>&-'; echo $?} ksh[1]: exec: 10: not found 127 +$ @kbd{dash -c 'exec 9>&-'; echo $?} +0 +$ @kbd{dash -c 'exec 10>&-'; echo $?} +exec: 1: 10: not found +2 @end example @c