aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xadd-group6
1 files changed, 5 insertions, 1 deletions
diff --git a/add-group b/add-group
index c27855c..fada716 100755
--- a/add-group
+++ b/add-group
@@ -29,7 +29,11 @@ if [ -n "$users" ]; then
IFS="$SAVED_IFS"
for u in $*; do
- /usr/sbin/usermod -G $name $u > /dev/null 2>&1
+ old=`egrep "[:,]$u(,|$)" /etc/group | cut -d : -f 1 | xargs echo`
+ if [ -n "$old" ]; then
+ old=`echo ",$old" | sed 's/ /,/g'`
+ fi
+ /usr/sbin/usermod -G $name$old $u > /dev/null 2>&1
done
fi