svn commit: r363421 - head/usr.sbin/pkg

Kyle Evans kevans at FreeBSD.org
Wed Jul 22 17:33:36 UTC 2020


Author: kevans
Date: Wed Jul 22 17:33:35 2020
New Revision: 363421
URL: https://svnweb.freebsd.org/changeset/base/363421

Log:
  pkg-bootstrap: complain on improper `pkg bootstrap` usage
  
  Right now, the bootstrap will gloss over things like pkg bootstrap -x or
  pkg bootstrap -f pkg. Make it more clear that this is incorrect, and hint
  at the correct formatting.
  
  Reported by:	jhb (IIRC via IRC)
  Approved by:	bapt, jhb, manu
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D24750

Modified:
  head/usr.sbin/pkg/pkg.c

Modified: head/usr.sbin/pkg/pkg.c
==============================================================================
--- head/usr.sbin/pkg/pkg.c	Wed Jul 22 14:32:47 2020	(r363420)
+++ head/usr.sbin/pkg/pkg.c	Wed Jul 22 17:33:35 2020	(r363421)
@@ -1050,8 +1050,16 @@ main(int argc, char *argv[])
 
 	if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) {
 		bootstrap_only = true;
-		if (argc == 3 && strcmp(argv[2], "-f") == 0)
+		if (argc > 3) {
+			fprintf(stderr, "Too many arguments\nUsage: pkg bootstrap [-f]\n");
+			exit(EXIT_FAILURE);
+		}
+		if (argc == 3 && strcmp(argv[2], "-f") == 0) {
 			force = true;
+		} else if (argc == 3) {
+			fprintf(stderr, "Invalid argument specified\nUsage: pkg bootstrap [-f]\n");
+			exit(EXIT_FAILURE);
+		}
 	}
 
 	if ((bootstrap_only && force) || access(pkgpath, X_OK) == -1) {


More information about the svn-src-head mailing list