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#18534 - pacman isn't quiet when it's supposed to be

Attached to Project: Pacman
Opened by Adam Dariusz Szkoda (adaszko) - Tuesday, 02 March 2010, 19:59 GMT
Last edited by Ionut Biru (wonder) - Tuesday, 02 March 2010, 20:39 GMT
Task Type Feature Request
Category Output
Status Assigned
Assigned To Dan McGee (toofishes)
Architecture All
Severity Low
Priority Normal
Reported Version 3.3.3
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 1
Private No

Details

Summary and Info:
The standard --quiet option semantics (established by many CLI tools) is: don't say anything until something bad happens. In some programs that behaviour is achieved by passing --quiet several times. Neither of these works in pacman.

When pacman is used in scripts, usually all that is interesting, is the exit code and side-effects.

Some will say to use >/dev/null, but what if I want to parse, for example, which packages were upgraded.

If detection of passing option several times is complicated, maybe there should another option, e.g. --batch whose output would be especially convenient for parsing/piping.

Uniformity across tools behaviour is very important IMO. It eliminates unpleasant surprises and unnecessary lookups to manual.


Steps to Reproduce:
Even with -q (--quiet) option, there's a multitude of cruft on terminal:

$ LANG= sudo pacman -Syq
:: Synchronizing package databases...
core is up to date
extra is up to date
community is up to date
archlinuxfr is up to date
archrepo is up to date
archstuff is up to date
arch-games is up to date
awesome is up to date
blind is up to date
danym is up to date
dragonlord is up to date
rfad is up to date
This task depends upon

Comment by Ionut Biru (wonder) - Tuesday, 02 March 2010, 20:31 GMT
in fact -q is not supposed to do what you described. The quick help says clearly: show less information for query and search

so do for example pacman -Ss thunderbird and then pacman -Ssq thunderbird or pacman -Ql something pacman -Qlq something
Comment by Adam Dariusz Szkoda (adaszko) - Tuesday, 02 March 2010, 20:49 GMT
Indeed, use of -q in -Ss or -Ql is very useful.
The problem is that there's no way to force pacman to output messages on errors only, like other tools do.
Comment by Allan McRae (Allan) - Wednesday, 03 March 2010, 04:06 GMT
Sure there is....
pacman -Syq > /dev/null
Comment by Adam Dariusz Szkoda (adaszko) - Wednesday, 03 March 2010, 07:23 GMT
Is it guaranteed that every error message goes to stderr?
Comment by Allan McRae (Allan) - Wednesday, 03 March 2010, 12:35 GMT
They all should go to stderr. If not, then I guess that would be considered a bug.
Comment by Adam Dariusz Szkoda (adaszko) - Wednesday, 03 March 2010, 16:01 GMT
I agree, though concerning the >/dev/null thing:

Here's a snippet from a /etc/cron.daily job in Perl:

sub upgrade_system {
system "pacman --sync --refresh --noprogressbar --quiet";
my @upgrades = `pacman --query --upgrades --quiet`;

# HERE: pacman should behave in such a way that line below would be unnecessary.
# If you don't know Perl, this removes first and last line from pacman's output.
shift @upgrades; pop @upgrades;

# Do nothing when there are no updates available.
@upgrades or return;

# Download updates.
system "pacman --sync --quiet --sysupgrade --noconfirm --downloadonly";

# Do the update.
my $upgrades = `pacman --sync --noconfirm --sysupgrade`;
send_mail (MAILTO, "System update summary", $upgrades);
}

And what do you get for `pacman --query --upgrades --quiet >/dev/null`? A nonsense is what you get.

So, if -q is meant for scripts (as pacman's man page mentions), why the shift;pop line is needed? It shouldn't be.

To me, the shift;pop line is a ugly hack. It undermines the confidence that some other useless message won't be added in the future.

Similar thing happens with -Sq:

$ sudo pacman -Sq gedit
resolving dependencies... <- USELESS IN SCRIPTS!
looking for inter-conflicts... <- DITTO
[...]

Also, -q should imply --noconfirm and --noprogressbar if it is to be used in scripts.
I recall that Debian's apt-get and dpkg are more polished in this respect.
Comment by Allan McRae (Allan) - Thursday, 04 March 2010, 03:37 GMT
> pacman --query --upgrades --quiet
enchant
jasper
smbclient
thunderbird

You seem to be doing it wrong... there is not top or bottom line to delete.


The -Sq <pkg> option is not documented to reduce output. The man page says it will have an effect of -Ss -Sl -Sg but nothing else. "pacman -Sq <pkg>" hard to justify for use in a script as 1) its output is not script friendly at all and 2) it is quite dangerous to script.
Comment by Adam Dariusz Szkoda (adaszko) - Thursday, 04 March 2010, 13:50 GMT
> You seem to be doing it wrong... there is not top or bottom line to delete.
Forgive me, my fault. I wrote that script a while ago and everything seamed to be working, which pushed me to wrong conclusions.

> The -Sq <pkg> option is not documented to reduce output. The man page says it will have an effect of -Ss -Sl -Sg but nothing else.
That's why this a feature request.

> "pacman -Sq <pkg>" hard to justify for use in a script as
> 1) its output is not script friendly at all and
Then it shouldn't output anything (with -q.)

> 2) it is quite dangerous to script.
Please leave that to the user. This is Unix, not Windows.

Loading...