autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] docs: mention bash bug with word splitting


From: Eric Blake
Subject: [PATCH 2/2] docs: mention bash bug with word splitting
Date: Tue, 3 Aug 2010 16:17:34 -0600

* doc/autoconf.texi (Shell Substitutions): Document bash bug, and
zsh default behavior difference.
Reported by Ralf Wildenhues.
---
 ChangeLog         |    5 +++++
 doc/autoconf.texi |   26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3d3ace6..7184742 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-08-03  Eric Blake  <address@hidden>

+       docs: mention bash bug with word splitting
+       * doc/autoconf.texi (Shell Substitutions): Document bash bug, and
+       zsh default behavior difference.
+       Reported by Ralf Wildenhues.
+
        docs: mention ksh bug with function syntax
        * doc/autoconf.texi (Shell Functions): Document ksh93 limitation.

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index e292062..b7e2c19 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -15283,6 +15283,32 @@ Shell Substitutions
 There is just no portable way to use double-quoted strings inside
 double-quoted back-quoted expressions (pfew!).

+Bash 4.1 has a bug where quoted empty strings adjacent to unquoted
+parameter expansions are elided during word splitting.  Meanwhile, zsh
+does not perform word splitting except when in Bourne compatibility
+mode.  In the example below, the correct behavior is to have five
+arguments to the function, and exactly two spaces on either side of the
+middle @samp{-}, since word splitting collapses multiple spaces in
address@hidden but leaves empty arguments intact.
+
address@hidden
+$ @kbd{bash -c 'n() @{ echo "$#$@@"; @}; f="  -  "; n - ""$f"" -'}
+3- - -
+$ @kbd{ksh -c 'n() @{ echo "$#$@@"; @}; f="  -  "; n - ""$f"" -'}
+5-  -  -
+$ @kbd{zsh -c 'n() @{ echo "$#$@@"; @}; f="  -  "; n - ""$f"" -'}
+3-   -   -
+$ @kbd{zsh -c 'emulate sh;}
+> @kbd{n() @{ echo "$#$@@"; @}; f="  -  "; n - ""$f"" -'}
+5-  -  -
address@hidden example
+
address@hidden
+You can work around this by doing manual word splitting, such as using
address@hidden"$str" $list} rather than @samp{"$str"$list}.
+
+There are also portability pitfalls with particular expansions:
+
 @table @code
 @item $@@
 @cindex @samp{"$@@"}
-- 
1.7.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]