summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-09-26 19:11:25 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-09-26 19:11:25 +0000
commitb7c315cdda2d1d189232c2cd36f3b2610914e5f3 (patch)
tree46cf5c041e19fc90f8a4571ac638f20291726d2c
parent412a3ca0b0e87c1be185aa344adff347a7559736 (diff)
downloadcoreutils-b7c315cdda2d1d189232c2cd36f3b2610914e5f3.tar.xz
[ChangeLog]
* NEWS: "groups user" no longer outputs "user :"; you need at least two users. "groups" now processes options like --help more compatibly. * src/groups.sh: Implement the option-processing change. Handle user and group names with special characters more robustly. Report write errors instead of exiting silently with status 1. [doc/ChangeLog] * coreutils.texi (groups invocation): "groups" no longer prefixes the output with "user :" unless more than one user is specified.
-rw-r--r--ChangeLog8
-rw-r--r--NEWS8
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/coreutils.texi3
-rwxr-xr-xsrc/groups.sh53
5 files changed, 55 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 7004dca4b..1f31f0886 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ * NEWS: "groups user" no longer outputs "user :"; you need at least
+ two users. "groups" now processes options like --help more compatibly.
+ * src/groups.sh: Implement the option-processing change.
+ Handle user and group names with special characters more robustly.
+ Report write errors instead of exiting silently with status 1.
+
2006-09-26 Jim Meyering <jim@meyering.net>
* README: Warn not to run autoreconf manually. Use bootstrap instead.
diff --git a/NEWS b/NEWS
index 50fbcc5f7..815b0762a 100644
--- a/NEWS
+++ b/NEWS
@@ -22,8 +22,14 @@ GNU coreutils NEWS -*- outline -*-
With --verbose (-v), cp and mv would sometimes generate no output,
or neglect to report file removal.
- "groups user" now exits nonzero when it gets a write error.
+ For the "groups" command:
+ "groups" no longer prefixes the output with "user :" unless more
+ than one user is specified; this is for compatibility with BSD.
+
+ "groups user" now exits nonzero when it gets a write error.
+
+ "groups" now processes options like --help more compatibly.
* Major changes in release 6.2 (2006-09-18) [stable candidate]
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 10e4109d7..2867798b0 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ * coreutils.texi (groups invocation): "groups" no longer prefixes
+ the output with "user :" unless more than one user is specified.
+
2006-09-19 Paul Eggert <eggert@cs.ucla.edu>
* coreutils.texi (cp invocation): Say that -i and -f are
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index bcc336f60..3a180f669 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -11973,7 +11973,8 @@ options}.
@command{groups} prints the names of the primary and any supplementary
groups for each given @var{username}, or the current process if no names
-are given. If names are given, the name of each user is printed before
+are given. If more than one name is given, the name of each user is
+printed before
the list of that user's groups. Synopsis:
@example
diff --git a/src/groups.sh b/src/groups.sh
index 43395d710..decbe6aaf 100755
--- a/src/groups.sh
+++ b/src/groups.sh
@@ -34,36 +34,49 @@ Report bugs to <@PACKAGE_BUGREPORT@>."
version='groups (@GNU_PACKAGE@) @VERSION@
Written by David MacKenzie.
-Copyright (C) 2004 Free Software Foundation, Inc.
+Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'
-fail=0
-case $# in
- 1 )
- case "z${1}" in
- z--help )
- echo "$usage" || fail=1; exit $fail;;
- z--version )
- echo "$version" || fail=1; exit $fail;;
- * ) ;;
- esac
- ;;
- * ) ;;
-esac
+for arg
+do
+ case $arg in
+ --help | --hel | --he | --h)
+ exec echo "$usage" ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v)
+ exec echo "$version" ;;
+ --)
+ shift
+ break ;;
+ -*)
+ echo "$0: invalid option: $arg" >&2
+ exit 1 ;;
+ esac
+done
# With fewer than two arguments, simply exec "id".
case $# in
- 0|1) exec id -Gn "$@" ;;
+ 0|1) exec id -Gn -- "$@" ;;
esac
# With more, we need a loop, and be sure to exit nonzero upon failure.
-for name in "$@"; do
- if groups=`id -Gn -- $name`; then
- echo $name : $groups || fail=1
+status=0
+write_error=0
+
+for name
+do
+ if groups=`id -Gn -- "$name"`; then
+ echo "$name : $groups" || {
+ status=$?
+ if test $write_error = 0; then
+ echo "$0: write error" >&2
+ write_error=1
+ fi
+ }
else
- fail=1
+ status=$?
fi
done
-exit $fail
+
+exit $status