On Fri, 3 Jul 2009, fsc-log-...@richardneill.org wrote: > Configuration Information [Automatically generated, do not change]: > Machine: i486 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL > -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 > -Wall > uname output: Linux fsc-log 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 > 01:57:59 UTC 2009 i686 GNU/Linux > Machine Type: i486-pc-linux-gnu > > Bash Version: 3.2 > Patch Level: 48 > Release Status: release > > Description: > Bash allows escape characters to be embedded by using the $'\n' > syntax. However, unlike all other $variables, > this doesn't work with embedded newlines. I think it should. > > Repeat-By: > X="a$'\n'b c" > echo "$X" > > expect to see: > a > b c > > actually see: > a$'\n'b c > > > Fix: > $'\n' should be expanded within double-quotes, like other variables > are. > Otherwise, please correct the man-page to make it clearer.
$'\n' is not a variable. As the man page says: Words of the form $'string' are treated specially. Note "Words". Inside double quotes, $'\n' is not a word. > > If this is a feature, not a bug, then is there a better way to include > newlines in a variable-assignment? > The syntax X="a"$'\n'"b c" will do it, but that is really really > ugly. X=$'a\nb c' -- Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com> =================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)