2015-05-11 23:50:25 +0200, Jo Drexl (FFGR-IT): > Hi guys, > I had to write a Windows bat file for twentysomething users and - as > Linux geek - wrote a small Bash script for it. The code in question is > as follows: > > echo -e "net use z: \\\\srv\\aqs /persistent:no /user:%USERNAME% > $BG_PASSWD\r" [...]
If that's a bash script, then that has nothing to do with GNU coreutils as bash has its own builtin version of echo. In any case, there's no bug here. and GNU coreutils echo or the bash one behave the same. \ is used as an escape character both for the bash language within double quotes, and for echo -e. echo -e "\\\\" Passes 3 arguments to echo: <echo>, <-e> and <\\> Same as echo -e '\\' And echo then treats \\ as an escaped \. You've got another problem in that escape sequences are expanded in your variables. Here, you want: printf '%s\r\n' "net use z: \\\\srv\\aqs /persistent:no /user:%USERNAME% $BG_PASSWD" or: printf '%s\r\n' 'net use z: \\srv\aqs /persistent:no /user:%USERNAME% '"$BG_PASSWD" or: printf 'net use z: \\\\srv\\aqs /persistent:no /user:%%USERNAME%% %s\r\n' "$BG_PASSWD" etc... -- Stephane