summaryrefslogtreecommitdiff
path: root/src/groups.c
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2013-09-21 14:15:45 +0200
committerBernhard Voelker <mail@bernhard-voelker.de>2013-09-21 14:15:45 +0200
commit2a0d241f69f7f3f5b826656a97f9bafb20bd8711 (patch)
tree3e23194ad9215ceee6f4f6cb2158b4f925318ea3 /src/groups.c
parentb3578fc9ffe70b9466687f9f6470a85f1a0ab14f (diff)
downloadcoreutils-2a0d241f69f7f3f5b826656a97f9bafb20bd8711.tar.gz
id: add -z, --zero option
* src/group-list.h (print_group_list): Add a parameter for the delimiter of type char. * src/group-list.c (print_group_list): Likewise, and use it instead of a white space character to delimit the group entries. * src/groups.c (main): Pass white space character to print_group_list(). * src/id.c (longopts): Add array element for the new long option. (usage): Document the new option. While at it, fix the alignment of the descriptions to match that of HELP_OPTION_DESCRIPTION. (main): Define the bool flag opt_zero indicating the use of the new option. In the getopt_long loop, handle it. Output an error diagnostic in the case the --zero option has been specified together with the default format. In the case of -gG, pass either a NUL or a white space character to print_group_list() - depending on the above new flag. Likewise change the printing of the final newline character: output a NUL instead if the --zero option has been specified. * doc/coreutils.texi (id invocation): Document the new option. While at it, move the @exitstatus macro down after the macro @primaryAndSupplementaryGroups in order to be consistent with other texinfo documents. (groups invocation): Move @exitstatus down after the macro @primaryAndSupplementaryGroups here, too. * tests/misc/id-zero.sh: Add new test exercising the new option. * tests/local.mk (all_tests): Reference it. * NEWS (New features): Mention the new option. Fixes http://bugs.gnu.org/9987
Diffstat (limited to 'src/groups.c')
-rw-r--r--src/groups.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/groups.c b/src/groups.c
index 53332d56b..d30c9fb41 100644
--- a/src/groups.c
+++ b/src/groups.c
@@ -114,13 +114,13 @@ main (int argc, char **argv)
if (rgid == NO_GID && errno)
error (EXIT_FAILURE, errno, _("cannot get real GID"));
- if (!print_group_list (NULL, ruid, rgid, egid, true))
+ if (!print_group_list (NULL, ruid, rgid, egid, true, ' '))
ok = false;
putchar ('\n');
}
else
{
- /* At least one argument. Divulge the details of the specified users. */
+ /* At least one argument. Divulge the details of the specified users. */
while (optind < argc)
{
struct passwd *pwd = getpwnam (argv[optind]);
@@ -130,7 +130,7 @@ main (int argc, char **argv)
rgid = egid = pwd->pw_gid;
printf ("%s : ", argv[optind]);
- if (!print_group_list (argv[optind++], ruid, rgid, egid, true))
+ if (!print_group_list (argv[optind++], ruid, rgid, egid, true, ' '))
ok = false;
putchar ('\n');
}