]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
docs: mention bash bug with word splitting
authorEric Blake <eblake@redhat.com>
Tue, 3 Aug 2010 21:56:07 +0000 (15:56 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 3 Aug 2010 22:10:04 +0000 (16:10 -0600)
* doc/autoconf.texi (Shell Substitutions): Document bash bug, and
zsh default behavior difference.
Reported by Ralf Wildenhues.

ChangeLog
doc/autoconf.texi

index 3d3ace6bed35380543403a5fc63a38c4146e5e3a..7184742eb03b8d9054d22be0b27ff8c3f77290be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-08-03  Eric Blake  <eblake@redhat.com>
 
+       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.
 
index e292062d7913d91ea19bd81f0f60e1064fcd45d0..b7e2c197f09be1f7b6f42f23b27ddd558592d543 100644 (file)
@@ -15283,6 +15283,32 @@ $ @kbd{echo "`echo \"hello\"`"}
 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
+@samp{$f} but leaves empty arguments intact.
+
+@example
+$ @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-  -  -
+@end example
+
+@noindent
+You can work around this by doing manual word splitting, such as using
+@samp{"$str" $list} rather than @samp{"$str"$list}.
+
+There are also portability pitfalls with particular expansions:
+
 @table @code
 @item $@@
 @cindex @samp{"$@@"}