Ethan Glasser-Camp wrote: > Hi, > > I'm not a shell script pro and I don't know much about POSIX, but I > have found this puzzling behavior in bash, and although it is > documented I don't really understand why bash behaves this way. I was > hoping someone could tell me. > > [EMAIL PROTECTED]:~$ set -H > [EMAIL PROTECTED]:~$ echo "hi!" > bash: !": event not found
Only single quotes or an unquoted backslash can inhibit history expansion. This is inherited from the features's csh heritage. > [EMAIL PROTECTED]:~$ echo "hi\!" > hi\! > > This is somewhat unusual; generally, characters protected by > backslashes are put through *unescaped*. Compare: > > [EMAIL PROTECTED]:~$ echo "\`" > ` > [EMAIL PROTECTED]:~$ echo "\"" > " > [EMAIL PROTECTED]:~$ echo "hi\$" > hi$ Not true, in general. Posix specifies the characters the backslash can escape in double-quoted strings. You happened to choose three of the five. 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> Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Live Strong. No day but today. Chet Ramey, ITS, CWRU [EMAIL PROTECTED] http://cnswww.cns.cwru.edu/~chet/