2 ms·
Is this macro from the article dangerous because it doesn't quote the argument? Control-j: "\C-a$(\C-e)" I can never remember how expansion and variable sub
by westurner 7y ago
Is this macro from the article dangerous because it doesn't quote the argument?
Control-j: "\C-a$(\C-e)"
I can never remember how expansion and variable substitution work in shells.
- dan-robertson 7y agoThe macro means: \C-a: beginning of line $: self-insert (: self-insert \C-e: end of line ): self-insert So if your prompt (with | for cursor) looks like this: grep 'blah blah' |some_file And you execute that macro, you get: $(grep 'blah blah' some_file)| Which is correctly quoted and I think always correctly quotes whatever is at the prompt (unless you e.g. get half way through a string and press enter so the beginning of the prompt is halfway through a string, or maybe if you have multiple lines)
- westurner 7y agoYeah, but this and this do different things: # prints a newline echo $(echo "-e a\nb") # prints "-e a\nb" echo "$(echo "-e a\nb")"