improve comments and use better variable names

This commit is contained in:
Matt Coddington 2012-02-07 12:38:21 -05:00
parent 4d845b3fea
commit 908e74689c

View file

@ -37,14 +37,15 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then
field=4 field=4
else else
# we were passed a group name. compare to current gid and # We were passed a group name. Compare the gid in
# set $current_value to $oldgid if it needs changing. # the user's /etc/passwd entry with the gid of the
newgid=$(awk -F: '{ print $3 }' "$__object/explorer/group") # group returned by the group explorer.
oldgid=$(awk -F: '{ print $4 }' "$file") gid_from_group=$(awk -F: '{ print $3 }' "$__object/explorer/group")
if [ "$newgid" != "$oldgid" ]; then gid_from_passwd=$(awk -F: '{ print $4 }' "$file")
current_value="$oldgid" if [ "$gid_from_group" != "$gid_from_passwd" ]; then
current_value="$gid_from_passwd"
else else
current_value=$new_value current_value="$new_value"
fi fi
fi fi
;; ;;
@ -58,6 +59,8 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
uid) field=3 ;; uid) field=3 ;;
esac esac
# If we haven't already set $current_value above, pull it from the
# appropriate file/field.
if [ -z "$current_value" ]; then if [ -z "$current_value" ]; then
export field export field
current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")" current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"