On 05/11/2015 04:14 PM, Pádraig Brady wrote:

>> echo -e "net use z: \\\\srv\\aqs /persistent:no /user:%USERNAME% 
>> $BG_PASSWD\r"

'echo -e' is non-portable.  POSIX recommends that you use printf
instead, as the POSIX version of echo is supposed to behave as follows:

$ echo -e 'a\nb'
-e a\nb

You are relying on non-POSIX behavior for backslash interpolation.

> Note echo is not portable to other systems, and if that's required,

In fact, it's not even portable to bash:

$ shopt -s xpg_echo

tells bash to turn on POSIX rules for echo, invalidating any bash script
that relies on 'echo -e'.

> printf(1) is a better option, though that will have different
> quoting again due to the % chars etc.

% doesn't need quoting in shell.  But yes, printf is more portable.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to