Welcome to the Pacman bug tracker. Please search the current bugs and feature requests before filing a new one! Use advanced search and select "Search in Comments".

* Please select the correct category and version.
* Write a descriptive summary, background info, and provide a reproducible test case whenever possible.

FS#59371 - pacman -Sp pkg1 pkg2 pkg3 should preserve the supplied order in output too

Attached to Project: Pacman
Opened by AMM (amish) - Tuesday, 17 July 2018, 17:20 GMT
Last edited by Eli Schwartz (eschwartz) - Tuesday, 17 July 2018, 17:55 GMT
Task Type General Gripe
Category Output
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 5.1.0
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No


Summary and Info:
Ok first of all - I would consider this as a bug but some may consider it as a feature request. I am fine either way.

When calling pacman -Sp one would expect that output is in same order as the supplied arguments.

But ...

# echo behave similar to "pacman -Sl" but for individual packages instead of whole repository
# pacman -Sp --print-format "%r %n %v" firefox glibc sqlite tzdata
core tzdata 2018e-1
core glibc 2.27-3
core sqlite 3.24.0-1
extra firefox 61.0.1-1

As one can see even if input is in sorted order - output is neither sorted order nor in input (supplied arguments) order. Its just random (because it lists dependencies first). Larger the list (say 300-400 names) - more the random-ness.

I believe the main purpose of -Sp --print-format is to make it script friendly. But due to above it makes scripting bit complicated. Because output is neither in supplied order nor in sorted order.

I know I can workaround this by using "%n %v %r" and then pipe it to sort. But then my idea is to represent the output in consistent fashion as "pacman -Sl" i.e. repository pkgname pkgver.

I know I can further workaround by swapping first two words. But it means more scripting / more parsing.

So overall this makes -Sp script unfriendly.

It would be great if supplied order is preserved.
This task depends upon

Closed by  Eli Schwartz (eschwartz)
Tuesday, 17 July 2018, 17:55 GMT
Reason for closing:  Won't fix
Comment by Eli Schwartz (eschwartz) - Tuesday, 17 July 2018, 17:52 GMT

You literally pointed out yourself "Its just random (because it lists dependencies first)" which is kind of the exact opposite of random.

pacman is explicitly ordering it according to dependency order, and I don't see why this should be a problem. It's definitely not a bug, you're simply disagreeing with a policy.
Comment by Eli Schwartz (eschwartz) - Tuesday, 17 July 2018, 17:54 GMT
And you haven't explained why it should be a problem either, except for the vague assertion that "it makes scripting bit complicated".

But I'm unsure why you need it to be in alphanumeric order of the pkgname anyway, and you could equally argue that doing it your way makes things complicated, because absolutely anything at all will be complicated if it doesn't do things exactly the way your exact use case needs.

If for some reason you actually do need this, well, the "sort" command allows you to sort by the second field instead of the first field. Problem solved, anyone can sort it however they like.

I see no reason to modify this explicit behavior.