Move the quiet flag into the configuration structure

This commit is contained in:
Baptiste Daroussin 2015-07-11 17:01:08 +00:00
parent f936ccb5f8
commit 8daa3a67ff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285396
4 changed files with 7 additions and 3 deletions

View File

@ -314,6 +314,9 @@ main(int argc, char *argv[])
case 'o':
conf.checkduplicate = true;
break;
case 'q':
conf.quiet = true;
break;
default:
addarg(&arglist, ch, optarg);
break;
@ -334,7 +337,7 @@ main(int argc, char *argv[])
* We should immediately look for the -q 'quiet' switch so that we
* don't bother with extraneous errors
*/
if (getarg(&arglist, 'q') != NULL)
if (conf.quiet)
freopen(_PATH_DEVNULL, "w", stderr);
/*

View File

@ -122,7 +122,7 @@ pw_group(int mode, char *name, long id, struct cargs * args)
};
if (mode == M_NEXT)
return (pw_groupnext(cnf, getarg(args, 'q') != NULL));
return (pw_groupnext(cnf, conf.quiet));
if (mode == M_LOCK || mode == M_UNLOCK)
errx(EX_USAGE, "'lock' command is not available for groups");

View File

@ -231,7 +231,7 @@ pw_user(int mode, char *name, long id, struct cargs * args)
cnf = conf.userconf;
if (mode == M_NEXT)
return (pw_usernext(cnf, getarg(args, 'q') != NULL));
return (pw_usernext(cnf, conf.quiet));
/*
* We can do all of the common legwork here

View File

@ -87,6 +87,7 @@ struct pwconf {
char *config;
int fd;
int which;
bool quiet;
bool dryrun;
bool pretty;
bool v7;