[Top][All Lists]

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

Re: echo backslash

From: Paul Jarc
Subject: Re: echo backslash
Date: Sat, 14 Sep 2002 22:55:16 -0400
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu)

address@hidden (Kenneth M. Howlett) wrote:
> You will probably say this is not a bug.

Right.  bash is behaving as intended.  It happens that the intended
behavior is complicated, but it's required for historical
compatibility.  See the QUOTING section of the man page if you want to
understand how (part of) it works.

> But I think this behavior is illogical and inconsistent.

sh is indeed an ugly language, but it's far too late to change it

> I do not think bash should drop the backslash in 'echo a\b'. If
> backslash substitution is not being done, the backslash should
> be treated as an ordinary character.
> In 'echo "a\b\\"', backslash substitution is
> done for '\\', but not for '\b'. This is inconsistent.

There are actually two separate mechanisms at work here, both
involving backslashes.  The first is quoting, which is done for all
commands, not just echo, and which does not depend on whether you
specified -e for echo.  The second mechanism is C-style special
character substitution for echo, which does depend on -e.  In your
example, quoting is in effect (as always), but -e is not.

> I think 'echo a\b' and 'echo "a\b"' should produce the same result.

Making that change would break lots of code that expects the current
behavior.  If you want an aethetically pleasing language, don't look
at sh derivatives.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]