/g/, when double quoting, why does bash not remove the backslash when escaping an exclamation mark?
Why does
"Hi\!"
expand to
Hi\!
and not
Hi!
???
history? just to fuck with people? gentoo?
Also, are there better alternatives to bash? It seems like the best standard shell, but honestly the syntax is kinda shit.
>>55775182
\ is used to include things.
for example if a path would have a space in a folder youd use \ to include the spaces to properly display it.
modern terminal emulators hide this from you though.
>>55775240
I think you don't understand my question. Here's an excerpt from the manual:
Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. The characters ‘$’ and ‘`’ retain their special meaning within double quotes (see Shell Expansions). The backslash retains its special meaning only when followed by one of the following characters: ‘$’, ‘`’, ‘"’, ‘\’, or newline. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding characters without a special meaning are left unmodified. A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an ‘!’ appearing in double quotes is escaped using a backslash. The backslash preceding the ‘!’ is not removed.
It's that last sentence that makes no sense.
For instance:
"Hi\"" => Hi"
while:
"Hi!-1" => touch self.txt
and:
"Hi\!-1" => Hi\!-1
It's really weird that it chooses to leave that backslash in there ONLY for !. Is this completely arbitrary? Is it to prevent interference with some other mechanism? Is it for historical raisins?
>GNU bash
I will be monitoring this thread, if not for the answer then at least because I like the way this /g/man talks.
Good eye for detail too.
>>55775182
History expansion is on?