mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Fix echo -n and read -r in scripts.
This commit is contained in:
		@@ -8,7 +8,7 @@
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# IDENTIFICATION
 | 
					# IDENTIFICATION
 | 
				
			||||||
#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.1 1999/12/04 04:53:21 momjian Exp $
 | 
					#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.2 1999/12/05 20:52:54 momjian Exp $
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Note - this should NOT be setuid.
 | 
					# Note - this should NOT be setuid.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
@@ -24,6 +24,16 @@ PwPrompt=
 | 
				
			|||||||
Password=
 | 
					Password=
 | 
				
			||||||
PSQLOPT=
 | 
					PSQLOPT=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check for echo -n vs echo \c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if echo '\c' | grep -s c >/dev/null 2>&1
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					    ECHO_N="echo -n"
 | 
				
			||||||
 | 
					    ECHO_C=""
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    ECHO_N="echo"
 | 
				
			||||||
 | 
					    ECHO_C='\c'
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while [ $# -gt 0 ]
 | 
					while [ $# -gt 0 ]
 | 
				
			||||||
do
 | 
					do
 | 
				
			||||||
@@ -92,19 +102,19 @@ fi
 | 
				
			|||||||
# Get missing user attributes
 | 
					# Get missing user attributes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$NewUser" ]; then
 | 
					if [ -z "$NewUser" ]; then
 | 
				
			||||||
	echo -n "Enter name of user to add: "
 | 
						$ECHO_N "Enter name of user to add: "$ECHO_C
 | 
				
			||||||
	read -r NewUser
 | 
						read NewUser
 | 
				
			||||||
	[ $? -ne 0 ] && exit 1
 | 
						[ $? -ne 0 ] && exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "$PwPrompt" ]; then
 | 
					if [ "$PwPrompt" ]; then
 | 
				
			||||||
	echo -n "Enter password for user $NewUser: "
 | 
						$ECHO_N "Enter password for user $NewUser: "$ECHO_C
 | 
				
			||||||
	read -r Password
 | 
						read Password
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$CanCreateDb" ]; then
 | 
					if [ -z "$CanCreateDb" ]; then
 | 
				
			||||||
	echo -n "Is the new user allowed to create databases? (y/n) "
 | 
						$ECHO_N "Is the new user allowed to create databases? (y/n) "$ECHO_C
 | 
				
			||||||
	read -r
 | 
						read REPLY
 | 
				
			||||||
	[ $? -ne 0 ] && exit 1
 | 
						[ $? -ne 0 ] && exit 1
 | 
				
			||||||
	if [ $REPLY = "y" -o $REPLY = "Y" ]; then
 | 
						if [ $REPLY = "y" -o $REPLY = "Y" ]; then
 | 
				
			||||||
		CanCreateDb=t
 | 
							CanCreateDb=t
 | 
				
			||||||
@@ -114,8 +124,8 @@ if [ -z "$CanCreateDb" ]; then
 | 
				
			|||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$CanAddUser" ]; then
 | 
					if [ -z "$CanAddUser" ]; then
 | 
				
			||||||
	echo -n "Shall the new user be allowed to create more new users? (y/n) "
 | 
						$ECHO_N "Shall the new user be allowed to create more new users? (y/n) "$ECHO_C
 | 
				
			||||||
	read -r
 | 
						read REPLY
 | 
				
			||||||
	[ $? -ne 0 ] && exit 1
 | 
						[ $? -ne 0 ] && exit 1
 | 
				
			||||||
	if [ $REPLY = "y" -o $REPLY = "Y" ]; then
 | 
						if [ $REPLY = "y" -o $REPLY = "Y" ]; then
 | 
				
			||||||
		CanAddUser=t
 | 
							CanAddUser=t
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# IDENTIFICATION
 | 
					# IDENTIFICATION
 | 
				
			||||||
#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.1 1999/12/04 04:53:21 momjian Exp $
 | 
					#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.2 1999/12/05 20:52:54 momjian Exp $
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#-------------------------------------------------------------------------
 | 
					#-------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -20,6 +20,17 @@ PSQLOPT=
 | 
				
			|||||||
dbname=
 | 
					dbname=
 | 
				
			||||||
forcedel=t
 | 
					forcedel=t
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check for echo -n vs echo \c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if echo '\c' | grep -s c >/dev/null 2>&1
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					    ECHO_N="echo -n"
 | 
				
			||||||
 | 
					    ECHO_C=""
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    ECHO_N="echo"
 | 
				
			||||||
 | 
					    ECHO_C='\c'
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while [ $# -gt 0 ]
 | 
					while [ $# -gt 0 ]
 | 
				
			||||||
do
 | 
					do
 | 
				
			||||||
    case "$1" in 
 | 
					    case "$1" in 
 | 
				
			||||||
@@ -75,8 +86,8 @@ fi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if [ "$forcedel" = f ]; then
 | 
					if [ "$forcedel" = f ]; then
 | 
				
			||||||
	echo "Database \"$dbname\" will be permanently deleted."
 | 
						echo "Database \"$dbname\" will be permanently deleted."
 | 
				
			||||||
	echo -n "Are you sure? (y/n) "
 | 
						$ECHO_N "Are you sure? (y/n) "$ECHO_C
 | 
				
			||||||
	read -r
 | 
						read REPLY
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ $? -eq 1 ] && exit 1
 | 
						[ $? -eq 1 ] && exit 1
 | 
				
			||||||
	[ "$REPLY" != "y" -a "$REPLY" != "Y" ] && exit 0
 | 
						[ "$REPLY" != "y" -a "$REPLY" != "Y" ] && exit 0
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# IDENTIFICATION
 | 
					# IDENTIFICATION
 | 
				
			||||||
#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.1 1999/12/05 20:02:48 momjian Exp $
 | 
					#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.2 1999/12/05 20:52:54 momjian Exp $
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#-------------------------------------------------------------------------
 | 
					#-------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -20,17 +20,6 @@ langname=
 | 
				
			|||||||
echo=
 | 
					echo=
 | 
				
			||||||
list=
 | 
					list=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Check for echo -n vs echo \c
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if echo '\c' | grep -s c >/dev/null 2>&1
 | 
					 | 
				
			||||||
then
 | 
					 | 
				
			||||||
    ECHO_N="echo -n"
 | 
					 | 
				
			||||||
    ECHO_C=""
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
    ECHO_N="echo"
 | 
					 | 
				
			||||||
    ECHO_C='\c'
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ----------
 | 
					# ----------
 | 
				
			||||||
# Get options, language name and dbname
 | 
					# Get options, language name and dbname
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# IDENTIFICATION
 | 
					# IDENTIFICATION
 | 
				
			||||||
#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.1 1999/12/04 04:53:21 momjian Exp $
 | 
					#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.2 1999/12/05 20:52:54 momjian Exp $
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Note - this should NOT be setuid.
 | 
					# Note - this should NOT be setuid.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
@@ -18,6 +18,17 @@ CMDNAME=`basename $0`
 | 
				
			|||||||
PSQLOPT=
 | 
					PSQLOPT=
 | 
				
			||||||
forcedel=t
 | 
					forcedel=t
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check for echo -n vs echo \c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if echo '\c' | grep -s c >/dev/null 2>&1
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					    ECHO_N="echo -n"
 | 
				
			||||||
 | 
					    ECHO_C=""
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    ECHO_N="echo"
 | 
				
			||||||
 | 
					    ECHO_C='\c'
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while [ $# -gt 0 ]
 | 
					while [ $# -gt 0 ]
 | 
				
			||||||
do
 | 
					do
 | 
				
			||||||
    case "$1" in
 | 
					    case "$1" in
 | 
				
			||||||
@@ -72,16 +83,16 @@ fi
 | 
				
			|||||||
# Prompt for username if missing
 | 
					# Prompt for username if missing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$DelUser" ]; then
 | 
					if [ -z "$DelUser" ]; then
 | 
				
			||||||
	echo -n "Enter name of user to delete: "
 | 
						$ECHO_N "Enter name of user to delete: "$ECHO_C
 | 
				
			||||||
	read -r NewUser
 | 
						read NewUser
 | 
				
			||||||
	[ $? -ne 0 ] && exit 1
 | 
						[ $? -ne 0 ] && exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "$forcedel" = f ]; then
 | 
					if [ "$forcedel" = f ]; then
 | 
				
			||||||
	echo "User \"$DelUser\" and any owned databases will be permanently deleted."
 | 
						echo "User \"$DelUser\" and any owned databases will be permanently deleted."
 | 
				
			||||||
	echo -n "Are you sure? (y/n) "
 | 
						$ECHO_N "Are you sure? (y/n) "$ECHO_C
 | 
				
			||||||
	read -r
 | 
						read REPLY
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ $? -eq 1 ] && exit 1
 | 
						[ $? -eq 1 ] && exit 1
 | 
				
			||||||
	[ "$REPLY" != "y" -a "$REPLY" != "Y" ] && exit 0
 | 
						[ "$REPLY" != "y" -a "$REPLY" != "Y" ] && exit 0
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user