Properly handles default values.
<!--
-$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
-->
<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>
#
#
# 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 $
#
#-------------------------------------------------------------------------
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
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"
# 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 $
#
#-------------------------------------------------------------------------
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
#
#
# 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.
#
;;
*)
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;
#
#
# 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 $
#
#-------------------------------------------------------------------------
;;
*)
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
# 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 $
#
#-------------------------------------------------------------------------
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
#
#
# 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.
#
;;
*)
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;
#
#
# 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 $
#
#-------------------------------------------------------------------------
;;
*)
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
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