Re: Recent changes to pkg argument parsing (https://reviews.freebsd.org/D49977)

From: Matthew Seaman <matthew_at_FreeBSD.org>
Date: Tue, 06 May 2025 09:04:30 UTC
On 06/05/2025 09:18, Dan Mahoney (Ports) wrote:
> For example, we've got a cron job on every box that gathers all our leaf packages into a file:
> 
> #!/bin/sh
> /usr/sbin/pkg query -e '%#r == 0' '%n-%v'
> 
> We now get warnings:
> 
> # /usr/local/libexec/pkgleaf
> pkg: invalid option -- e
> 
> (but the query still runs).
> 
> Has anyone else seen this?

This is pkg(7) struggling to parse options that it doesn't do anything 
with other than pass them through to the real pkg(8).

As said elsewhere in the thread, a fix for the problem has been 
committed to base.  Until that makes its way through the system into a 
release, you can work around the problem by changing your command to:

/usr/local/sbin/pkg query -e '%#r == 0' '%n-%v'

ie. call pkg(8) directly rather than via pkg(7).

	Cheers,

	Matthew