Code

pgtest.sh: Pass additional arguments to client and start.
authorSebastian Harl <sh@tokkee.org>
Mon, 30 Apr 2012 14:29:31 +0000 (16:29 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 30 Apr 2012 14:29:31 +0000 (16:29 +0200)
Also, check for any additional arguments in all other commands.

pgtest.sh

index b88bf6c54938636d0f50f55dcae1c9de03c2615d..692de5e610abdb27bb5c72b1d702241d560c9163 100755 (executable)
--- a/pgtest.sh
+++ b/pgtest.sh
@@ -44,6 +44,11 @@ set -e
 
 case "$1" in
        setup)
+               if test $# -ne 1; then
+                       echo "Too many arguments!" >&2
+                       echo "Usage: $0 setup" >&2
+                       exit 1
+               fi
                mkdir -p $TARGET/var/lib/postgresql/main
                mkdir -p $TARGET/var/run/postgresql
                mkdir -p $TARGET/var/log/postgresql/main
@@ -66,16 +71,24 @@ case "$1" in
                                export LD_PRELOAD="$LD_PRELOAD:$libreadline"
                        fi
                fi
-               $BIN_DIR/psql -h $TARGET/var/run/postgresql/ -p 5435
+               shift
+               $BIN_DIR/psql -h $TARGET/var/run/postgresql/ -p 5435 "$@"
                ;;
        stop)
+               if test $# -ne 1; then
+                       echo "Too many arguments!" >&2
+                       echo "Usage: $0 setup" >&2
+                       exit 1
+               fi
                $BIN_DIR/pg_ctl -D $TARGET/var/lib/postgresql/main stop
                ;;
        start)
-               if test "$2" = "-B"; then
-                       $BIN_DIR/pg_ctl -D $TARGET/var/lib/postgresql/main -l logfile -w start
+               shift
+               if test "$1" = "-B"; then
+                       shift
+                       $BIN_DIR/pg_ctl -D $TARGET/var/lib/postgresql/main -l logfile -w start "$@"
                else
-                       $BIN_DIR/postgres -D $TARGET/var/lib/postgresql/main
+                       $BIN_DIR/postgres -D $TARGET/var/lib/postgresql/main "$@"
                fi
                ;;
        *)