Pacman

Historical bug tracker for the Pacman package manager.

The pacman bug tracker has moved to gitlab:
https://gitlab.archlinux.org/pacman/pacman/-/issues

This tracker remains open for interaction with historical bugs during the transition period. Any new bugs reports will be closed without further action.
Tasklist

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
Task Type Support Request
Category General
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 3.4.1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

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

Closed by  Dan McGee (toofishes)
Sunday, 12 December 2010, 00:50 GMT
Reason for closing:  Not a bug
Comment by Xavier (shining) - Saturday, 11 December 2010, 21:46 GMT
Try the same with grep.
grep -lts /var/log/pacman.log
Comment by guido (qqqqqqqqq9) - Saturday, 11 December 2010, 21:58 GMT
From http://www.gnu.org/software/bash/manual/bashref.html

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.
Comment by Loui Chang (louipc) - Saturday, 11 December 2010, 23:37 GMT
Maybe I should have omitted the first example. I understand that it behaves as expected.
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.
Comment by Dan McGee (toofishes) - Sunday, 12 December 2010, 00:49 GMT
I'm closing this; this is standard getopt behavior. If you need an argument starting with a '-', you have to use --, whether you quote it or not (which makes zero difference). The rest of it is just bash interpreting the command line. Prefix every 'pacman' with echo and you'll see exactly what is getting passed through to the program.

$ 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

Loading...