Here's a function that allows create simple user accounts in a htpasswd file.
Code:
printf "\nThe team has the following members:\n"
cat $VAR_TEAM_ROOT/auth | cut -d: -f1
printf "\nEnter member with password to add:\n"
# until get an empty member name or password
MEMBER=1
PASSWORD=1
until [ -z "$MEMBER" ] || [ -z "$PASSWORD" ]
do
read MEMBER PASSWORD
LISTING_TEST "$VAR_TEAM_ROOT/auth" "$MEMBER"
if [ "$?" = 1 ]
then
printf "[\e[1;32m+\e[m]\n"
# add to auth file
htpasswd -b $VAR_TEAM_ROOT/auth $MEMBER $PASSWORD &> /dev/null
# set trac permissions
trac-admin $VAR_TEAM_ROOT/trac permission remove "$MEMBER" &> /dev/null
trac-admin $VAR_TEAM_ROOT/trac permission add "$MEMBER" developer &> /dev/null
else
printf "[\e[1;31m-\e[m]\n"
fi
done
LISTING_TEST verifies the value entered against the list of users already in the file and returns "1" in case user is not found (what we basically need). In this case user gets added to the file and a "[+]" sign is printed on the next line.
The question is: how can I make the sign appear on the same line name and pass are displayed?
So that it would look like
user password [
+]
Just out of ideas

. Thanks.