Skip to content

Commit 0847fea

Browse files
committed
Allow prompting of create/drop user to handle spaces.
1 parent 5804a7c commit 0847fea

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/bin/scripts/createuser

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.24 2002/04/12 09:37:10 momjian Exp $
12+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.25 2002/04/12 09:42:31 momjian Exp $
1313
#
1414
# Note - this should NOT be setuid.
1515
#
@@ -27,6 +27,10 @@ Password=
2727
PSQLOPT=
2828
Encrypted= # blank uses default
2929

30+
# These handle spaces/tabs in identifiers
31+
_IFS="$IFS"
32+
NL="
33+
"
3034
# Check for echo -n vs echo \c
3135

3236
if echo '\c' | grep -s c >/dev/null 2>&1
@@ -178,19 +182,25 @@ trap 'stty echo >/dev/null 2>&1' 1 2 3 15
178182

179183
if [ -z "$NewUser" ]; then
180184
$ECHO_N "Enter name of user to add: "$ECHO_C
181-
read NewUser
185+
IFS="$NL"
186+
read NewUser
187+
IFS="$_IFS"
182188
[ "$?" -ne 0 ] && exit 1
183189
fi
184190

185191
if [ "$PwPrompt" ]; then
186192
$ECHO_N "Enter password for user \"$NewUser\": "$ECHO_C
187193
stty -echo >/dev/null 2>&1
194+
IFS="$NL"
188195
read FirstPw
196+
IFS="$_IFS"
189197
stty echo >/dev/null 2>&1
190198
echo
191199
$ECHO_N "Enter it again: "$ECHO_C
192200
stty -echo >/dev/null 2>&1
201+
IFS="$NL"
193202
read SecondPw
203+
IFS="$_IFS"
194204
stty echo >/dev/null 2>&1
195205
echo
196206
if [ "$FirstPw" != "$SecondPw" ]; then

src/bin/scripts/dropuser

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.16 2002/04/12 09:37:11 momjian Exp $
12+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.17 2002/04/12 09:42:32 momjian Exp $
1313
#
1414
# Note - this should NOT be setuid.
1515
#
@@ -22,6 +22,10 @@ PSQLOPT=
2222
forcedel=t
2323
DelUser=
2424

25+
# These handle spaces/tabs in identifiers
26+
_IFS="$IFS"
27+
NL="
28+
"
2529
# Check for echo -n vs echo \c
2630

2731
if echo '\c' | grep -s c >/dev/null 2>&1
@@ -125,7 +129,9 @@ fi
125129

126130
if [ -z "$DelUser" ]; then
127131
$ECHO_N "Enter name of user to delete: "$ECHO_C
128-
read DelUser
132+
IFS="$NL"
133+
read DelUser
134+
IFS="$_IFS"
129135
[ "$?" -ne 0 ] && exit 1
130136
fi
131137

0 commit comments

Comments
 (0)