Am Mittwoch 19 September 2007 schrieb Michelle Konzack: Hi Michelle! > Am 2007-09-19 16:59:12, schrieb Gregor Schneider: > > Was wertet die Shell denn hier aus? Bisher war mir nicht bewusst, > > dass ein Ausrufezeichen vor einem doppelten Anfuehrungszeichen > > irgendeine Funktion in der Shell beinhaltet. > > Das ist ein BASH-Bug Nope. Sondern dokumentiertes Verhalten: man bash: 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, !. [...] If enabled, history expan- sion will be performed unless an ! appearing in double quotes is escaped using a backslash. The backslash preceding the ! is not removed. man zshall: Overview A history expansion begins with the first character of the histchars parameter, which is `!' by default, and may occur anywhere on the command line; history expansions do not nest. The `!' can be escaped with `\' or can be enclosed between a pair of single quotes ('') to suppress its special meaning. Double quotes will not work for this. Following this history character is an optional event designator (see the section `Event Designators') and then an optional word designator (the section `Word Designators'); if neither of these designators is present, no history expansion occurs. Demnach auch in der Z-Shell: martin@shambala:~> echo $SHELL /usr/bin/zsh martin@shambala:~> echo "Hallo!" dquote> " Hallo Die Shell nimmt das " als Teil des mit ! expandierten History Expansion-Ausdrucks. Mit Escaping klappt es hingegen: martin@shambala:~> echo "Hallo\!" Hallo! Und so funktioniert diese History-Expansion - füge die letzte Zeile aus der History ein, die mit dem Begriff beginnt, der dem ! folgt: martin@shambala:~> echo "!e" echo "echo "Hallo\!"" echo Hallo! martin@shambala:~> martin@shambala:~> free total used free shared buffers cached Mem: 1555000 594484 960516 0 0 296320 -/+ buffers/cache: 298164 1256836 Swap: 1953968 8 1953960 martin@shambala:~> echo !f echo free free martin@shambala:~> !f free total used free shared buffers cached Mem: 1555000 594476 960524 0 0 296320 -/+ buffers/cache: 298156 1256844 Swap: 1953968 8 1953960 martin@shambala:~> Aber: martin@shambala:~> echo Hallo! Hallo! Da dem ! weder ein Ereignis-Kennzeichner noch ein Begriff folgt. Interessanter finde ich jedoch: martin@shambala:~> echo "Hallo, Martin\!" Hallo, Martin! martin@shambala:~> ^Martin^Michelle^ echo "Hallo, Michelle\!" Hallo, Michelle! martin@shambala:~> ;) Ciao, -- Martin 'Helios' Steigerwald - http://www.Lichtvoll.de GPG: 03B0 0D6C 0040 0710 4AFA B82F 991B EAAC A599 84C7
Attachment:
signature.asc
Description: This is a digitally signed message part.