Commit a974522f authored by Bruce Momjian's avatar Bruce Momjian

Added single-letter options and case statement.

parent 2d456c47
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.9 1996/10/04 20:07:10 scrappy Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.10 1996/10/05 03:24:47 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -57,34 +57,50 @@ noclean=0 ...@@ -57,34 +57,50 @@ noclean=0
template_only=0 template_only=0
POSTGRES_SUPERUSERNAME=$USER POSTGRES_SUPERUSERNAME=$USER
for ARG ; do while [ "$#" -gt 0 ]
# We would normally use e.g. ${ARG#--username=} to parse the options, but do
# there is a bug in some shells that makes that not work (BSD4.4 sh, # ${ARG#--username=} is not reliable or available on all platforms
# September 1996 -- supposed to be fixed in later release). So we bypass
# the bug with this sed mess. case "$1" in
--debug|-d)
username_sed=`echo $ARG | sed s/^--username=//` debug=1
pgdata_sed=`echo $ARG | sed s/^--pgdata=//` echo "Running with debug mode on."
;;
if [ $ARG = "--debug" -o $ARG = "-d" ]; then --noclean|-n)
debug=1 noclean=1
echo "Running with debug mode on." echo "Running with noclean mode on. Mistakes will not be cleaned up."
elif [ $ARG = "--noclean" -o $ARG = "-n" ]; then ;;
noclean=1 --template|-t)
echo "Running with noclean mode on. Mistakes will not be cleaned up." template_only=1
elif [ $ARG = "--template" ]; then echo "updating template1 database only."
template_only=1 ;;
echo "updating template1 database only." --username=*)
elif [ $username_sed. != $ARG. ]; then POSTGRES_SUPERUSERNAME="`echo $1 | sed s/^--username=//`"
POSTGRES_SUPERUSERNAME=$username_sed ;;
elif [ $pgdata_sed. != $ARG. ]; then -u)
PGDATA=$pgdata_sed shift
else POSTGRES_SUPERUSERNAME="$1"
echo "Unrecognized option '$ARG'. Syntax is:" ;;
echo "initdb [--template] [--debug] [--noclean]" \ -u*)
"[--username=SUPERUSER] [--pgdata=DATADIR]" POSTGRES_SUPERUSERNAME="`echo $1 | sed s/^-u//`"
exit 100 ;;
fi --pgdata=*)
PGDATA="`echo $1 | sed s/^--pgdata=//`"
;;
-r)
shift
PGDATA="$1"
;;
-r*)
PGDATA="`echo $1 | sed s/^-r//`"
;;
*)
echo "Unrecognized option '$1'. Syntax is:"
echo "initdb [-t | --template] [-d | --debug] [-n | --noclean]" \
"[-u SUPSERUSER | --username=SUPERUSER] [-r DATADIR | --pgdata=DATADIR]"
exit 100
esac
shift
done done
if [ "$debug" -eq 1 ]; then if [ "$debug" -eq 1 ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment