From eda4fd25f173f9f08a99760d115a0c3a0568666a Mon Sep 17 00:00:00 2001 From: bapt Date: Fri, 13 Apr 2018 18:25:00 +0000 Subject: [PATCH] pkg: accept -y and --yes from arguments By popular demand, pkg now walks thought the arguments passed and if it finds -y or --yes it does accept those as equivalent of ASSUME_ALWAYS_YES env var. Requested by: many MFC after: 1 week --- usr.sbin/pkg/pkg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 79fc826d83cb..d22598dc36a5 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -1032,6 +1032,7 @@ main(int argc, char *argv[]) { char pkgpath[MAXPATHLEN]; const char *pkgarg; + int i; bool bootstrap_only, force, yes; bootstrap_only = false; @@ -1083,6 +1084,15 @@ main(int argc, char *argv[]) * tucked in there already. */ config_bool(ASSUME_ALWAYS_YES, &yes); + if (!yes) { + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-y") == 0 || + strcmp(argv[i], "--yes") == 0) { + yes = true; + break; + } + } + } if (!yes) { if (!isatty(fileno(stdin))) { fprintf(stderr, non_interactive_message);