]> granicus.if.org Git - postgresql/commitdiff
Fix param handling of create* admin scripts as described months ago.
authorBruce Momjian <bruce@momjian.us>
Mon, 18 Feb 2002 05:48:45 +0000 (05:48 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 18 Feb 2002 05:48:45 +0000 (05:48 +0000)
Properly handles default values.

doc/src/sgml/ref/vacuumdb.sgml
src/bin/scripts/createdb
src/bin/scripts/createlang.sh
src/bin/scripts/createuser
src/bin/scripts/dropdb
src/bin/scripts/droplang
src/bin/scripts/dropuser
src/bin/scripts/vacuumdb

index 57420d6f51823ceda431c598e9519e5ee1416fd1..b1c3cab01a8383b3b74aa84c478c32f8a6a38681 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.20 2001/12/08 03:24:40 thomas Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.21 2002/02/18 05:48:43 momjian Exp $
 PostgreSQL documentation
 -->
 
@@ -23,13 +23,13 @@ PostgreSQL documentation
   <cmdsynopsis>
    <command>vacuumdb</command>
    <arg rep="repeat"><replaceable>connection-options</replaceable></arg>
-   <arg><arg>-d</arg> <replaceable>dbname</replaceable></arg>
    <group><arg>--full</arg><arg>-f</arg></group>
    <group><arg>--verbose</arg><arg>-v</arg></group>
    <group><arg>--analyze</arg><arg>-z</arg></group>
-   <arg>--table '<replaceable>table</replaceable>
+   <arg>--table | -t '<replaceable>table</replaceable>
     <arg>( <replaceable class="parameter">column</replaceable> [,...] )</arg>'
    </arg>
+   <arg><replaceable>dbname</replaceable></arg>
    <sbr>
    <command>vacuumdb</command>
    <arg rep="repeat"><replaceable>connection-options</replaceable></arg>
index 95e8c12d75755360209f0de3d357153ddeecf286..345624404619e1c5332cd1aea45e99f053be3e39 100644 (file)
@@ -12,7 +12,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.18 2001/09/30 22:17:51 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.19 2002/02/18 05:48:44 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -104,11 +104,17 @@ do
                exit 1
                ;;
        *)
-               if [ -z "$dbname" ]; then
-                       dbname="$1"
-               else
+               dbname="$1"
+               if [ "$2" ]
+               then
+                       shift
                        dbcomment="$1"
                fi
+               if [ "$#" -ne 1 ]; then
+                       echo "$CMDNAME: invalid option: $2" 1>&2
+                       echo "Try '$CMDNAME --help' for more information." 1>&2
+                       exit 1
+               fi
                ;;
     esac
     shift
@@ -118,7 +124,7 @@ if [ "$usage" ]; then
         echo "$CMDNAME creates a PostgreSQL database."
         echo
        echo "Usage:"
-        echo "  $CMDNAME [options] dbname [description]"
+        echo "  $CMDNAME [options] [dbname] [description]"
         echo
        echo "Options:"
        echo "  -D, --location=PATH             Alternative place to store the database"
index 881257157bc4613df0d07c124793ebb1f39923ef..5034f65cbe666ada4b0e1c221682e89b0e3d9910 100644 (file)
@@ -7,7 +7,7 @@
 # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.32 2002/01/03 05:30:04 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.33 2002/02/18 05:48:44 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -116,6 +116,11 @@ do
                        fi
                else    dbname="$1"
                fi
+               if [ "$#" -ne 1 ]; then
+                       echo "$CMDNAME: invalid option: $2" 1>&2
+                       echo "Try '$CMDNAME --help' for more information." 1>&2
+                       exit 1
+               fi
                 ;;
     esac
     shift
index fa20aa101cfdda1c3dd3a300b0993709226f5373..02e97c58c4242cfd6f2005b804fd2233adbd9f77 100644 (file)
@@ -9,7 +9,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.22 2001/09/30 22:17:51 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.23 2002/02/18 05:48:44 momjian Exp $
 #
 # Note - this should NOT be setuid.
 #
@@ -123,6 +123,11 @@ do
                ;;
          *)
                NewUser="$1"
+               if [ "$#" -ne 1 ]; then
+                       echo "$CMDNAME: invalid option: $2" 1>&2
+                       echo "Try '$CMDNAME --help' for more information." 1>&2
+                       exit 1
+               fi
                ;;
     esac
     shift;
index 75ad3cea76262e8d2586cd40712b55f183f4f9f9..42ff00a0a1515375351572af7235962b2dcffa96 100644 (file)
@@ -11,7 +11,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.13 2001/09/30 22:17:51 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.14 2002/02/18 05:48:44 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -89,6 +89,11 @@ do
                ;;
         *)
                dbname="$1"
+               if [ "$#" -ne 1 ]; then
+                       echo "$CMDNAME: invalid option: $2" 1>&2
+                       echo "Try '$CMDNAME --help' for more information." 1>&2
+                       exit 1
+               fi
                ;;
     esac
     shift
index b56d73ec354ed2f02f0bb2904f59d33622b9681e..579c570cf72cbabe50851b659ed8311202258f8e 100644 (file)
@@ -7,7 +7,7 @@
 # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.20 2002/01/03 08:53:00 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.21 2002/02/18 05:48:44 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -105,6 +105,11 @@ do
                        fi
                else    dbname="$1"
                fi
+               if [ "$#" -ne 1 ]; then
+                       echo "$CMDNAME: invalid option: $2" 1>&2
+                       echo "Try '$CMDNAME --help' for more information." 1>&2
+                       exit 1
+               fi
                 ;;
     esac
     shift
index ed95ec6c7390aae8cf09816355fda1272704b68f..298710ee3b7b57cd87cb41abdc97bc2b3a7e21c1 100644 (file)
@@ -9,7 +9,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.14 2001/09/30 22:17:51 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.15 2002/02/18 05:48:45 momjian Exp $
 #
 # Note - this should NOT be setuid.
 #
@@ -91,6 +91,11 @@ do
                ;;
          *)
                DelUser="$1"
+               if [ "$#" -ne 1 ]; then
+                       echo "$CMDNAME: invalid option: $2" 1>&2
+                       echo "Try '$CMDNAME --help' for more information." 1>&2
+                       exit 1
+               fi
                ;;
     esac
     shift;
index 35c8cc4b3bd3b6e944f2cc1375562d0b6112dc55..b14991d178d679f639d185e12093ad5ababf11ef 100644 (file)
@@ -12,7 +12,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.19 2001/09/30 22:17:51 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.20 2002/02/18 05:48:45 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -112,6 +112,11 @@ do
                ;;
        *)
                dbname="$1"
+               if [ "$#" -ne 1 ]; then
+                       echo "$CMDNAME: invalid option: $2" 1>&2
+                       echo "Try '$CMDNAME --help' for more information." 1>&2
+                       exit 1
+               fi
                ;;
     esac
     shift
@@ -151,9 +156,12 @@ if [ "$alldb" ]; then
        dbname=`${PATHNAME}psql $PSQLOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database WHERE datallowconn'`
 
 elif [ -z "$dbname" ]; then
-       echo "$CMDNAME: missing required argument: database name" 1>&2
-        echo "Try '$CMDNAME -?' for help." 1>&2
-       exit 1
+        if [ "$PGUSER" ]; then
+                dbname="$PGUSER"
+        else
+                dbname=`${PATHNAME}pg_id -u -n`
+        fi
+        [ "$?" -ne 0 ] && exit 1
 fi
 
 for db in $dbname