diff options
author | Jim Meyering <jim@meyering.net> | 2006-09-26 09:46:35 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-09-26 09:46:35 +0000 |
commit | bbab62fd272c6ae29f4f46dce81cc10d33c9ffea (patch) | |
tree | 357ecbb569348d9652000cf18d53a8101fc88678 | |
parent | 5f65d05616fa46fa892c4ee550c6f4df2f4d0b03 (diff) | |
download | coreutils-bbab62fd272c6ae29f4f46dce81cc10d33c9ffea.tar.xz |
* src/groups.sh: When invoked with 0 or 1 argument, just exec "id".
Rewrite to avoid using temporary, $status.
-rw-r--r-- | ChangeLog | 3 | ||||
-rwxr-xr-x | src/groups.sh | 27 |
2 files changed, 16 insertions, 14 deletions
@@ -1,5 +1,8 @@ 2006-09-26 Jim Meyering <jim@meyering.net> + * src/groups.sh: When invoked with 0 or 1 argument, just exec "id". + Rewrite to avoid using temporary, $status. + * NEWS: Mention the bug fix. * src/groups.sh: Don't hide a write failure. Reported by Iain Calder <ic56@rogers.com>. diff --git a/src/groups.sh b/src/groups.sh index dc64d12f1..43395d710 100755 --- a/src/groups.sh +++ b/src/groups.sh @@ -53,18 +53,17 @@ case $# in * ) ;; esac -if [ $# -eq 0 ]; then - id -Gn - fail=$? -else - for name in "$@"; do - groups=`id -Gn -- $name` - status=$? - if test $status = 0; then - echo $name : $groups || fail=1 - else - fail=$status - fi - done -fi +# With fewer than two arguments, simply exec "id". +case $# in + 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 + else + fail=1 + fi +done exit $fail |