Here's a patch to mention two shell portability problems, that I noticed during
gnulib work 
<https://lists.gnu.org/archive/html/bug-gnulib/2020-09/msg00080.html>.


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.

>From e41b8b2b2a59ee765e2c7b583be68101c2da52eb Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Fri, 18 Sep 2020 01:17:38 +0200
Subject: [PATCH] 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.
---
 doc/autoconf.texi | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 43df8f3..164175b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -15645,6 +15645,18 @@ $ @kbd{dash -c ': 1<>file'; cat file}
 $ rm a
 @end example
 
+Solaris 10 @code{sh} executes redirected compound commands in a subshell,
+while other shells don't:
+
+@example
+$ @kbd{sh -c 'foo=0; foo=1 2>/dev/null; echo $foo'}
+1
+$ @kbd{sh -c 'foo=0; @{ foo=1; @} 2>/dev/null; echo $foo'}
+0
+$ @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.
 
@@ -15745,8 +15757,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}:
+Solaris @command{ksh} and @command{dash} 0.5.8 don't understand any file
+descriptor larger than @samp{9}:
 
 @example
 $ @kbd{bash -c 'exec 10>&-'; echo $?}
@@ -15756,6 +15768,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 <https://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
-- 
2.7.4

Reply via email to