/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
* Copyright (C) 1996
* David L. Nugent. All rights reserved.
*
}
if ((istty = isatty(fd))) {
- n = t;
- /* Disable echo */
- n.c_lflag &= ~(ECHO);
- tcsetattr(fd, TCSANOW, &n);
- printf("%sassword for group %s:", update ? "New p" : "P",
- grp->gr_name);
- fflush(stdout);
+ if (tcgetattr(fd, &t) == -1)
+ istty = 0;
+ else {
+ n = t;
+ /* Disable echo */
+ n.c_lflag &= ~(ECHO);
+ tcsetattr(fd, TCSANOW, &n);
+ printf("%sassword for group %s:",
+ update ? "New p" : "P",
+ grp->gr_name);
+ fflush(stdout);
+ }
}
b = read(fd, line, sizeof(line) - 1);
if (istty) { /* Restore state */
struct userconf *cnf;
const char *cfg = NULL;
int ch;
- bool quiet;
+ bool quiet = false;
- while ((ch = getopt(argc, argv, "Cq")) != -1) {
+ while ((ch = getopt(argc, argv, "C:q")) != -1) {
switch (ch) {
case 'C':
cfg = optarg;
pw_group_show(int argc, char **argv, char *arg1)
{
struct group *grp = NULL;
- char *name;
+ char *name = NULL;
intmax_t id = -1;
int ch;
bool all, force, quiet, pretty;
grp_add_members(&grp, newmembers);
}
+ if (dryrun) {
+ print_group(grp, pretty);
+ return (EXIT_SUCCESS);
+ }
+
if ((rc = chggrent(name, grp)) != 0) {
if (rc == -1)
errx(EX_IOERR, "group '%s' not available (NIS?)",