[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20553: 'echo -e' does not escape backslash correctly
From: |
Erik Auerswald |
Subject: |
bug#20553: 'echo -e' does not escape backslash correctly |
Date: |
Tue, 12 May 2015 09:34:24 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
On Mon, May 11, 2015 at 11:17:34PM +0100, Stephane Chazelas wrote:
> 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 <\\>
So you need to add another handful of \ characters:
$ echo -e "\\\\\\\\"
\\
$ /bin/echo -e "\\\\\\\\"
\\
Erik