Re: evaluation of env variables in DASH

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

 



On 10/19/2011 03:24 PM, Dima Sorkin wrote:
Hi.
   The following DASH behaviour seems buggy to me

The only bug here is your expectations.


-----------------
$ export A='\n'
$ echo $A


Passing a literal backslash to echo is non-portable. POSIX even says so. And bash can match dash behavior:

$ (shopt -s xpg_echo; A='\n'; echo -$A-)
-
-

eblake@office (0) ~/libvirt
$ (shopt -u xpg_echo; A='\n'; echo -$A-)
-\n-

Fix your shell script to use printf instead of echo if the thing you are printing might contain a backslash.

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux