aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg/pkg.7
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@freebsdfoundation.org>2025-04-23 10:27:35 +0000
committerEd Maste <emaste@FreeBSD.org>2025-08-27 21:42:53 +0000
commit62947e5081616bff1e9623a0e4292e92b49c3910 (patch)
tree52db84a91866ce1626e1825459b63e708b0d3c37 /usr.sbin/pkg/pkg.7
parent1235e1d16085de69f87fbea68a80e070cf360019 (diff)
pkg: clarify argument parsing
Currently pkg parses all arguments and subcommands in a single getopt_long() loop. This results in quite a bit of accidental complexity, especially around the -r option for the bootstrap and add subcommands. This also results in the undocumented behavior of all options understood by pkg(7) being accepted anywhere in the argument list regardless of their position. This contradicts the behavior of pkg(8) and I find it quite unexpected. This patch splits the argument parsing done by pkg(7) into two phases for global options and subcommand options. This gives behavior that matches pkg(8), accepting the subset of pkg(8) options supported by pkg(7) in the exact same positions that pkg(8) accepts them. This is however a somewhat breaking change, as options are no longer accepted by pkg(7) in places they are rejected by pkg(8). For example, `pkg -f bootstrap` no longer works, only `pkg bootstrap -f`. The original motivation for writing this patch was investigating support for --rootdir in pkg(7). Since pkg(8) uses -r as the short form for both --rootdir and --repository depending on the position, I decided that pkg(7) needed to be brought inline with pkg(8)'s argument parsing behavior to avoid confusion. This patch also gets rid of args_add_message (unused since 40b9f924b1) Relnotes: yes Reviewed by: bapt Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49977 (cherry picked from commit be61deae0aa2923bb9908fc5b37b35712603e622) pkg: suppress error on unknown options pkg(7) does not understand all the options that pkg(8) understands and should never log errors about unknown options that it will pass on to pkg(8) without touching. PR: 286510 Reviewed by: bapt Fixes: be61deae0aa2 ("pkg: clarify argument parsing") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50163 (cherry picked from commit 73ba568b1c35aabc1682540b5b4d5d77220c5468)
Diffstat (limited to 'usr.sbin/pkg/pkg.7')
-rw-r--r--usr.sbin/pkg/pkg.75
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.sbin/pkg/pkg.7 b/usr.sbin/pkg/pkg.7
index 467f62d5747b..d2246f74a3fc 100644
--- a/usr.sbin/pkg/pkg.7
+++ b/usr.sbin/pkg/pkg.7
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 30, 2025
+.Dd April 29, 2025
.Dt PKG 7
.Os
.Sh NAME
@@ -33,8 +33,9 @@
.Op Fl d
.Ar command ...
.Nm
+.Op Fl d
.Cm add
-.Op Fl dfy
+.Op Fl fy
.Op Fl r Ar reponame
.Ar pkg.pkg
.Nm