bug-bash
[Top][All Lists]
Advanced

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

Re: inconsistent treatment of backslash-bang


From: Chet Ramey
Subject: Re: inconsistent treatment of backslash-bang
Date: Mon, 21 Jul 2008 09:32:54 -0400
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)

Lawrence D'Oliveiro wrote:
Chet Ramey wrote:

csh allows backslash to act as an escape character
(that is, it is removed) when it precedes ! in a double-quoted string.
Bash doesn't ...

But if it doesn't, then why does bang not have its history-expansion
behaviour? Either it's acting as an escape or it isn't. Which is it supposed
to be?

This is my last message on the subject.  It's becoming a time sink.  I
can only say the same thing so many times.

Bash and csh both permit backslash to inhibit history expansion when in
double quotes.  If you think of expansion as a series of individual steps,
at the conclusion of the "history expansion" step (which actually happens
very early on in the parsing process), the \! appears in the contents of
the double-quoted string.

Later on, in the subsequent word expansion steps, bash and csh differ.  csh
allows backslash to act as an escape character when it precedes `!' in a
double-quoted string, and removes it.  Bash allows backslash to act as an
escape character only when it precedes the characters so specified in the
Posix standard, and `!' is not one of those, so bash leaves the \! intact.

If you want to call that inconsistent, so be it.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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