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
This commit is contained in:
Baptiste Daroussin 2018-04-13 18:25:00 +00:00
parent e69f393430
commit 8e877d85dc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=332484

View File

@ -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);