4 ms·
You need to use single quotes. !, $, `, \ are expanded inside of double quotes.
by mqt 17y ago
You need to use single quotes. !, $, `, \ are expanded inside of double quotes.
- barrkel 17y agoI know about variable and command substitution and escaping, it makes sense that those expand inside " but not ' - but history expansion, something seemingly inherent to the interactive REPL, seems out of place here.
- eb 17y agoSpecial characters are substituted in double quotes. They're treated as literals in single quotes. Seems pretty consistent to me.
- barrkel 17y agoAliases are handled differently though, before e.g. file glob expansion. I would have expected history to be handled similarly.
- weaksauce 17y agoI understand your comment. Intuitively I agree with you but in the context of one of the original devs writing bash it would make no sense to tie the history command to the interactive REPL. Treating everything the same would lead to less bugs in "their" system while leaving a caveat for all the userland script writers.
- blasdel 17y agoThere is no difference between a script and the REPL. Besides, you'd expect variables to be expanded inside normal strings -- why special-case the other expansions?
- barrkel 17y agoI'd expect them to be handled in the same "phase" as alias expansions. See here for one example of hackery with aliases, that take advantage of their different expansion phase: http://www.chiark.greenend.org.uk/~sgtatham/aliases.html http://www.chiark.greenend.org.uk/~sgtatham/aliases.html