bug-bash
[Top][All Lists]
Advanced

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

Re: escaping exclamation in double quoted string


From: Bob Proulx
Subject: Re: escaping exclamation in double quoted string
Date: Sat, 28 Jul 2007 13:56:47 -0600
User-agent: Mutt/1.5.9i

Please keep replies to the mailing list so that others can participate
in the discussion and any answers will be archived.  Thanks.

John Tromp wrote:
> That is perfectly clear!
> 
> However, the question remains: what is the rationale of that specification?

I was not part of the decision and can only imagine this is
documenting and standardizing on the behavior of the existing programs
at the time the standard was written.  The '!' behavior of csh had a
number of quirks and this was one of them and it flowed into later
shells.  But since there was only one implementation and that is what
it did when the standard was written I imagine it simply froze in time
the behavior.  They did not mandate new behavior as part of the
standard.  In later years standards bodies have started mandating
never-before-seen new behavior when writing standards as part of a
clean up and extend vision.  That brings its own problems.

> The idea of "escaping" a '!' with a backslash is rather lost if the
> escaping character shows through. Wouldn't it be more useful to
> remove the backslash?  Now, when I want to echo the 3 characters
> '!', I have to do something like echo "'"'!'"'"  whereas true
> escaping would allow the more readable echo "'\!'"

I can't disagree.  But it is the way that it has always been.

Bob

John Tromp wrote:
> dear Bob,
> 
> >The important part for this is:
> >
> >  "The backslash preceding the ! is not removed."
> >
> >This is also required by the POSIX docs.
> >
> >  
> > http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02_01
> >
> >  The backslash shall retain its special meaning as an escape character
> >  (see Escape Character (Backslash)) only when followed by one of the
> >  following characters when considered special:
> >
> >      $   `   "   \   <newline>
> >
> >Hope that helps.
> 
> That is perfectly clear!
> 
> However, the question remains: what is the rationale of that specification?
> 
> The idea of "escaping" a '!' with a backslash is rather lost if the 
> escaping character
> shows through. Wouldn't it be more useful to remove the backslash?
> Now, when I want to echo the 3 characters '!', I have to do something like
> echo "'"'!'"'"
> whereas true escaping would allow the more readable
> echo "'\!'"
> 
> regards,
> -John
> 




reply via email to

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