Also ich muss ja sagen, ich habe schon so manches Minütchen (Stündchen?) "vor man bash verbracht", aber darüber bin ich bisher noch nicht gestolpert, wobei das ein mehrfacher Stolperer sein muss, bis man es so halbwegs nachvollziehen kann.
Code:
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, !.
----------------------------------------
HISTORY EXPANSION
------------------------------------
metacharacter-separated words surrounded by quotes are considered one word. History expansions are introduced by the appearance of the history expansion character, which is ! by default. Only
backslash (\) and single quotes can quote the history expansion character.
Several characters inhibit history expansion if found immediately following the history expansion character, even if it is unquoted: space, tab, newline, carriage return, and =. If the extglob
shell option is enabled, ( will also inhibit expansion.
--------------------------------------
The shell allows control of the various characters used by the history expansion mechanism (see the description of histchars above under Shell Variables).
-------------------------------------
histchars
The two or three characters which control history expansion and tokenization (see HISTORY EXPANSION below). The first character is the history expansion character, the character which sig-
nals the start of a history expansion, normally `!'. The second character is the quick substitution character, which is used as shorthand for re-running the previous command entered, sub-
stituting one string for another in the command. The default is `^'. The optional third character is the character which indicates that the remainder of the line is a comment when found
as the first character of a word, normally `#'. The history comment character causes history substitution to be skipped for the remaining words on the line. It does not necessarily cause
the shell parser to treat the rest of the line as a comment
Der Übersichtlichkeit halber einiges zwischen den Ausführungen im Abschnitt "HISTORY EXPANSION" entfernt, also ein klarer Fall von "in Prinzip ja" und "in der Regel ......" (hatten die Wikinger rote Bärte ... -ja ich weiß, schlechter Scherz-)
Kurzfassung:
Zitat von
https://www.linuxquestions.org/questions/programming-9/bash-double-quotes-dont-protect-exclamation-marks-545662/
You can turn off this annoying behaviour by setting histchars to an empty string:
//Nachtrag:
Die "Kurzfassung" würde ich aber niemandem empfehlen, der Scripte schreibt, die möglichst portabel sein sollen, sonst läuft der Kram zwar auf der eigenen aber es knallt dementsprechend auf einer anderen Kiste.
Greetz,
RM
Lesezeichen