You are not logged in.

#1 2022-06-09 16:36:26

watham
Member
From: United States
Registered: 2022-04-24
Posts: 9

[SOLVED] pacman --print-format doesn't format?

I've read the man page, check the wiki in the spots that seem relevant and can't seem to find anything relevant about gotchas. But, I've come across a need to modify the standard output behaviour for pacman and it does have the --print-format option. Although, if a typical: "pacman -Ss <package>" is changed to: "pacman -Ss --print-format "%n" <package>" I get no change it output. It prints the standard two-line 'repo/name version\ndescription' that is typical.

Tried;
1.  pacman -Ss --print-format "%n" <package>, no dice
2.  pacman --print-format "%n" -Ss <package>, no dice
3.  pacman --print --print-format "%n" -Ss <package>, no dice
4.  pacman --print -Ss print-format "%n" <package>, no dice

Nothing seems to alter the output. These are just for demonstration. I know if all I wanted was a list of names the "-q" option is avaialable on a search and it will provide that, but that's not my ultimate goal. This is where I'm starting and the starting block doesn't work, no sense going further and just banging my head against a wall.

What's wrong with my commandline?

.--.                  Pacman v6.0.1 - libalpm v13.0.1
/ _.-' .-.  .-.  .-.   Copyright (C) 2006-2021 Pacman Development Team
\  '-. '-'  '-'  '-'   Copyright (C) 2002-2006 Judd Vinet
'--'
                       This program may be freely redistributed under
                       the terms of the GNU General Public License.

Sincerely,
Nathan

Last edited by watham (2022-06-09 17:37:56)

Offline

#2 2022-06-09 17:24:23

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,420
Website

Re: [SOLVED] pacman --print-format doesn't format?

--print-format only applies to -Sp/-Rp/-Up


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#3 2022-06-09 17:34:37

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] pacman --print-format doesn't format?

Try community/expac.

Offline

#4 2022-06-09 17:37:39

watham
Member
From: United States
Registered: 2022-04-24
Posts: 9

Re: [SOLVED] pacman --print-format doesn't format?

Wouldn't it be clever if -h and the man page actually mentioned that specifically. There was something in --print (-p) about using --print-format to customize the output. Altough the man page specifically lists --print-format under "TRANSACTION OPTIONS (APPLY TO -S, -R AND -U)" *sigh* should tell us the sub options it only works for too I suppose. Ironically I had tried "-Ss --print --print-format ..." which was unsuccessfull.

Thanks!

Offline

#5 2022-06-09 17:47:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] pacman --print-format doesn't format?

watham wrote:

Wouldn't it be clever if -h and the man page actually mentioned that specifically.

No, clever would be actually reading the man page before posting a comment like that:

man pacman (emphasis added) wrote:

--print-format <format>
           Specify a printf-like format to control the output of the --print operation.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2022-06-09 19:13:28

watham
Member
From: United States
Registered: 2022-04-24
Posts: 9

Re: [SOLVED] pacman --print-format doesn't format?

Trilby wrote:

No, clever would be actually reading the man page before posting a comment like that:

Instead of just being a d***, show me where it explains -p and -s are mutually exclusive since you want to be so snarky. I don't see it. I already alluded to the fact I read that. My blonde moment or not, never used the --print option, and it's also not specified as mutually exclusive in this context or *any* for that matter.

My comment is more like "oh well, life goes on ..." I understand documentation doesn't always match reality and here's a perfect case. I'm not some entitled individual but I did check the documentation and am very confused since none of my examples seemed to do what the documentation indicated they should.

Many options under -S can be combined and wouldn't it make sense you could control the output of -s by doing something like "pacman -Ssp --print-format "....." <package>"?  IDK, to me that makes sense. Neither under -s for -Q or -s for -S does it say it ignore -p. Under -p it does NOT say it is ignored by -s. In fact -p is listed as "TRANSACTION OPTIONS (APPLY TO -S, -R AND -U)", doesn't that imply it APPLIES to EVERYTHING under -S -R and -U unless otherwise noted?

If you treat other Newbie Corners like this in the future, you're not a good addition to this board.

Last edited by watham (2022-06-09 19:22:49)

Offline

#7 2022-06-09 19:28:45

watham
Member
From: United States
Registered: 2022-04-24
Posts: 9

Re: [SOLVED] pacman --print-format doesn't format?

Raynman wrote:

Try community/expac.

Thank you! I have it installed, and it really is more like what should be used in the context of what I wanted. I was using yay and noticed the print-format and figured it was passed through, so checked the man page in pacman and started reading more. There didn't seem to be a documented restriction for combining "search" and "print" under "sync", so that's where my confusion was! Now I see that there's no need to use "search" as using "print" alone with search for a given argument and output using the supplied --print-format.

Sincerely,
Nathan

Offline

#8 2022-06-09 19:30:52

watham
Member
From: United States
Registered: 2022-04-24
Posts: 9

Re: [SOLVED] pacman --print-format doesn't format?

Alad wrote:

--print-format only applies to -Sp/-Rp/-Up

? that's where there was a breakdown in my understanding. While print-format says to use it with --print, --print doesn't say you can't use it with other things in the "Sync" option set so I was assuming a --search was still needed, but it isn't.

Thank you for your help! I've marked the thread as [SOLVED] with this after a little tinkering.

Offline

#9 2022-06-09 19:40:45

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,420
Website

Re: [SOLVED] pacman --print-format doesn't format?

I also got confused by this part the first time I read it. I don't know of a technical reason why -p does not apply to operation options like -s though. That might be something to discuss on the pacman-dev mailing list.


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#10 2022-06-10 01:31:25

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] pacman --print-format doesn't format?

watham wrote:

Instead of just being a d***, show me where it explains -p and -s are mutually exclusive

watham wrote:

--print doesn't say you can't use it with other things in the "Sync" option set

Yes it does.

man pacman wrote:

-p, --print                                                                                                                   
           Only print the targets instead of performing the actual operation (sync, remove or upgrade).

But go ahead, and just call me a dick again rather than acknowledging the facts in front of you.

Last edited by Trilby (2022-06-10 01:31:51)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#11 2022-06-10 03:12:14

watham
Member
From: United States
Registered: 2022-04-24
Posts: 9

Re: [SOLVED] pacman --print-format doesn't format?

Trilby wrote:
watham wrote:

Instead of just being a d***, show me where it explains -p and -s are mutually exclusive

watham wrote:

--print doesn't say you can't use it with other things in the "Sync" option set

Yes it does.

man pacman wrote:

-p, --print                                                                                                                   
           Only print the targets instead of performing the actual operation (sync, remove or upgrade).

But go ahead, and just call me a dick again rather than acknowledging the facts in front of you.

And where does it say that -S (Notice it's a capital S smarty pants) "sync" then doesn't work at all? In fact you cannot use --print as a single option it must be coupled with one of those three options. Try it since you point that out. Based on how that's written you can't "sync" but "pacman --print" is impossible.

So "pacman -S --print <package>" is how it works. So how does that stop the actual operation?  Oh, /right/ it PRINTS. That is EXACTLY what I wanted to do. As I indicated in my original post I understood there was something related with --print-format and --print. I also knew a list was possible to see with just using "-q". Maybe *you* should work on your reading comprehension here since -S and -s are different options in pacman. Where in *anything* have you showed any documentation that says they're mutually exclusive?

So again, don't be a d***. Doesn't matter how many thousands of posts you have.

Offline

#12 2022-06-10 07:26:13

progandy
Member
Registered: 2012-05-17
Posts: 5,319

Re: [SOLVED] pacman --print-format doesn't format?

"sync" is a description of the operation, not a flag in this case.

Last edited by progandy (2022-06-10 08:18:59)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#13 2022-06-10 08:11:10

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] pacman --print-format doesn't format?

A search is not a sync (install), remove or upgrade and it doesn't operate on targets, but on search terms given as regexps. Search already prints its results, so specifying --print as well seems nonsensical. Still, it could be nice if --print-format worked with other operations.

You never properly explained EXACTLY what you wanted to do ("my ultimate goal"). From the use of <package> instead of <search term> in the examples, we could have deduced that you didn't actually want to do a search operation with regexps, but you're making a big fuss over how things should be clearly spelled out.

The man page could maybe be a little clearer, but I think it's good enough. You first have to work out that pacman is a bit unusual though, compared to other package managers or other commands with operations/subcommands (like git/btrfs/...). There's the syntax (operations given as flags), but also consider this: -S by itself is an operation. Some flags only change some aspects of this operation a bit, but others turn it into a completely different operation. Looking at -Ss/-Qs and -Si/-Qi, you could say the operation is actually search/info and there's a required flag (-S/-Q) to specify which db to query. Because the db is different, there are small differences in the output and as you extend this way of looking at (sub)operations to -g and -l, the differences become more pronounced.

Offline

#14 2022-06-10 10:07:53

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,579
Website

Re: [SOLVED] pacman --print-format doesn't format?

I understand the frustration, but there is no need to resort to name calling. As this has been marked as solved, I'm going to close the topic before it becomes any more heated.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB