Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81c0383

Browse files
committed
Fix echo -n and read -r in scripts.
1 parent60ae5ed commit81c0383

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

‎src/bin/scripts/createuser

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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=
2424
Password=
2525
PSQLOPT=
2626

27+
# Check for echo -n vs echo \c
28+
29+
ifecho'\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

2838
while [$#-gt 0 ]
2939
do
@@ -92,19 +102,19 @@ fi
92102
# Get missing user attributes
93103

94104
if [-z"$NewUser" ];then
95-
echo -n"Enter name of user to add:"
96-
read-rNewUser
105+
$ECHO_N"Enter name of user to add:"$ECHO_C
106+
read NewUser
97107
[$?-ne 0 ]&&exit 1
98108
fi
99109

100110
if ["$PwPrompt" ];then
101-
echo -n"Enter password for user$NewUser:"
102-
read-rPassword
111+
$ECHO_N"Enter password for user$NewUser:"$ECHO_C
112+
read Password
103113
fi
104114

105115
if [-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+
readREPLY
108118
[$?-ne 0 ]&&exit 1
109119
if [$REPLY="y"-o$REPLY="Y" ];then
110120
CanCreateDb=t
@@ -114,8 +124,8 @@ if [ -z "$CanCreateDb" ]; then
114124
fi
115125

116126
if [-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+
readREPLY
119129
[$?-ne 0 ]&&exit 1
120130
if [$REPLY="y"-o$REPLY="Y" ];then
121131
CanAddUser=t
@@ -142,4 +152,4 @@ if [ $? -ne 0 ]; then
142152
exit 1
143153
fi
144154

145-
exit 0
155+
exit 0

‎src/bin/scripts/dropdb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
#
1212
# IDENTIFICATION
13-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.1 1999/12/04 04:53:21 momjian Exp $
13+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.2 1999/12/05 20:52:54 momjian Exp $
1414
#
1515
#-------------------------------------------------------------------------
1616

@@ -20,6 +20,17 @@ PSQLOPT=
2020
dbname=
2121
forcedel=t
2222

23+
# Check for echo -n vs echo \c
24+
25+
ifecho'\c'| grep -s c>/dev/null2>&1
26+
then
27+
ECHO_N="echo -n"
28+
ECHO_C=""
29+
else
30+
ECHO_N="echo"
31+
ECHO_C='\c'
32+
fi
33+
2334
while [$#-gt 0 ]
2435
do
2536
case"$1"in
@@ -75,8 +86,8 @@ fi
7586

7687
if ["$forcedel"= f ];then
7788
echo"Database\"$dbname\" will be permanently deleted."
78-
echo -n"Are you sure? (y/n)"
79-
read-r
89+
$ECHO_N"Are you sure? (y/n)"$ECHO_C
90+
readREPLY
8091

8192
[$?-eq 1 ]&&exit 1
8293
["$REPLY"!="y"-a"$REPLY"!="Y" ]&&exit 0
@@ -89,4 +100,4 @@ if [ $? -ne 0 ]; then
89100
exit 1
90101
fi
91102

92-
exit 0
103+
exit 0

‎src/bin/scripts/droplang

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010
# IDENTIFICATION
11-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.1 1999/12/05 20:02:48 momjian Exp $
11+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.2 1999/12/05 20:52:54 momjian Exp $
1212
#
1313
#-------------------------------------------------------------------------
1414

@@ -20,17 +20,6 @@ langname=
2020
echo=
2121
list=
2222

23-
# Check for echo -n vs echo \c
24-
25-
ifecho'\c'| grep -s c>/dev/null2>&1
26-
then
27-
ECHO_N="echo -n"
28-
ECHO_C=""
29-
else
30-
ECHO_N="echo"
31-
ECHO_C='\c'
32-
fi
33-
3423

3524
# ----------
3625
# Get options, language name and dbname

‎src/bin/scripts/dropuser

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010
# IDENTIFICATION
11-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.1 1999/12/04 04:53:21 momjian Exp $
11+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.2 1999/12/05 20:52:54 momjian Exp $
1212
#
1313
# Note - this should NOT be setuid.
1414
#
@@ -18,6 +18,17 @@ CMDNAME=`basename $0`
1818
PSQLOPT=
1919
forcedel=t
2020

21+
# Check for echo -n vs echo \c
22+
23+
ifecho'\c'| grep -s c>/dev/null2>&1
24+
then
25+
ECHO_N="echo -n"
26+
ECHO_C=""
27+
else
28+
ECHO_N="echo"
29+
ECHO_C='\c'
30+
fi
31+
2132
while [$#-gt 0 ]
2233
do
2334
case"$1"in
@@ -72,16 +83,16 @@ fi
7283
# Prompt for username if missing
7384

7485
if [-z"$DelUser" ];then
75-
echo -n"Enter name of user to delete:"
76-
read-rNewUser
86+
$ECHO_N"Enter name of user to delete:"$ECHO_C
87+
read NewUser
7788
[$?-ne 0 ]&&exit 1
7889
fi
7990

8091

8192
if ["$forcedel"= f ];then
8293
echo"User\"$DelUser\" and any owned databases will be permanently deleted."
83-
echo -n"Are you sure? (y/n)"
84-
read-r
94+
$ECHO_N"Are you sure? (y/n)"$ECHO_C
95+
readREPLY
8596

8697
[$?-eq 1 ]&&exit 1
8798
["$REPLY"!="y"-a"$REPLY"!="Y" ]&&exit 0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp