-if [ $# -eq 0 ]
-then
-
- while true
- do
- echo -n "Add to group(s) [other] (separate by space, ? for list): "
- read ans
- [ -z "$ans" ] && ans=other
- if [ "X$ans" = "X?" ]
- then
- for d in $SRC_GROUPS; do
- l=$(sed -n < tests/$d/group \
- -e 's/#.*//' \
- -e 's/$/ /' \
- -e 's;\(^[0-9][0-9][0-9]\)\(.*$\);\2;p')
- grpl="$grpl $l"
- done
- lst=`for word in $grpl; do echo $word; done | sort| uniq `
- echo $lst
- else
- # only allow lower cases, spaces, digits and underscore in group
- inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
- if [ "$inval" != "" ]; then
- echo "Invalid characters in group(s): $inval"
- echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
- continue
- else
- # remove redundant spaces/tabs
- ans=`echo "$ans" | sed 's/\s\+/ /g'`
- break
- fi
- fi
- done
-else
- # expert mode, groups are on the command line
- #
- for g in $*
- do
- if ! grep -q "[[:space:]]$g" "$tdir/group"; then
- echo "Warning: group \"$g\" not defined in $tdir/group"
- fi
- done
- ans="$*"
-fi
-
-echo -n "Adding $id to group index ..."
-head -n $(($line-1)) $tdir/group > /tmp/$$.group
-echo "$id $ans" >> /tmp/$$.group
-tail -n +$((line)) $tdir/group >> /tmp/$$.group
-mv /tmp/$$.group $tdir/group