88#
99#
1010# IDENTIFICATION
11- # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.1 1999/12/04 04:53:21 momjian Exp $
11+ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.2 1999/12/05 20:52:54 momjian Exp $
1212#
1313# Note - this should NOT be setuid.
1414#
@@ -24,6 +24,16 @@ PwPrompt=
2424Password=
2525PSQLOPT=
2626
27+ # Check for echo -n vs echo \c
28+
29+ if echo ' \c' | grep -s c> /dev/null2>&1
30+ then
31+ ECHO_N=" echo -n"
32+ ECHO_C=" "
33+ else
34+ ECHO_N=" echo"
35+ ECHO_C=' \c'
36+ fi
2737
2838while [$# -gt 0 ]
2939do
92102# Get missing user attributes
93103
94104if [-z " $NewUser " ]; then
95- echo -n " Enter name of user to add:"
96- read -r NewUser
105+ $ECHO_N " Enter name of user to add:" $ECHO_C
106+ read NewUser
97107[$? -ne 0 ]&& exit 1
98108fi
99109
100110if [" $PwPrompt " ]; then
101- echo -n " Enter password for user$NewUser :"
102- read -r Password
111+ $ECHO_N " Enter password for user$NewUser :" $ECHO_C
112+ read Password
103113fi
104114
105115if [-z " $CanCreateDb " ]; then
106- echo -n " Is the new user allowed to create databases? (y/n)"
107- read -r
116+ $ECHO_N " Is the new user allowed to create databases? (y/n)" $ECHO_C
117+ read REPLY
108118[$? -ne 0 ]&& exit 1
109119if [$REPLY = " y" -o $REPLY = " Y" ]; then
110120CanCreateDb=t
@@ -114,8 +124,8 @@ if [ -z "$CanCreateDb" ]; then
114124fi
115125
116126if [-z " $CanAddUser " ]; then
117- echo -n " Shall the new user be allowed to create more new users? (y/n)"
118- read -r
127+ $ECHO_N " Shall the new user be allowed to create more new users? (y/n)" $ECHO_C
128+ read REPLY
119129[$? -ne 0 ]&& exit 1
120130if [$REPLY = " y" -o $REPLY = " Y" ]; then
121131CanAddUser=t
@@ -142,4 +152,4 @@ if [ $? -ne 0 ]; then
142152exit 1
143153fi
144154
145- exit 0
155+ exit 0