FS#22062 - search: Switch and search term confusion
Attached to Project:
Pacman
Opened by Loui Chang (louipc) - Saturday, 11 December 2010, 21:44 GMT
Last edited by Dan McGee (toofishes) - Sunday, 12 December 2010, 00:50 GMT
Opened by Loui Chang (louipc) - Saturday, 11 December 2010, 21:44 GMT
Last edited by Dan McGee (toofishes) - Sunday, 12 December 2010, 00:50 GMT
|
Details
I got some unexpected results when I searched for "-lts"
At first I used: pacman -Ss -lts This gave me all results as expected. My mistake. So I surrounded the term in quotes: pacman -Ss "-lts" Same result, so I finally decided to escape the dash: pacman -Ss -- -lts and pacman -Ss '\-lts' Those both worked as I expected. This does not: pacman -Ss \-lts I'm not sure what the intended behaviour is, but it did catch me off guard. |
This task depends upon
grep -lts /var/log/pacman.log
3.1.2.1 Escape Character
A non-quoted backslash ‘\’ is the Bash escape character. It preserves the literal value of the next character that follows, with the exception of newline.
What about the second example though? I never would have thought that I'd have to both
quote and escape. I must have never started a search term or argument with a dash before.
Crazy.
Thanks for answering my dumb questions.
$ echo pacman -Ss -lts
pacman -Ss -lts
$ echo pacman -Ss -lts
pacman -Ss -lts
$ echo pacman -Ss "-lts"
pacman -Ss -lts
$ echo pacman -Ss -- -lts
pacman -Ss -- -lts
$ echo pacman -Ss '\-lts'
pacman -Ss \-lts
$ echo pacman -Ss \-lts
pacman -Ss -lts