/*-
+ * 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 */
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;