88#
99#
1010# IDENTIFICATION
11- # $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.21 2001/07/1104:57:34 momjian Exp $
11+ # $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.22 2001/07/1116:16:52 momjian Exp $
1212#
1313# -------------------------------------------------------------------------
1414
7979if echo " $0 " | grep' /' > /dev/null2>&1
8080then
8181# explicit dir name given
82- self_path=` echo$0 | sed' s,/[^/]*$,,' ` # (dirname command is not portable)
82+ self_path=` echo" $0 " | sed' s,/[^/]*$,,' ` # (dirname command is not portable)
8383else
8484# look for it in PATH ('which' command is not portable)
8585for dir in ` echo" $PATH " | sed' s/:/ /g' `
@@ -116,7 +116,7 @@ shutdown_mode=smart
116116
117117while [" $# " -gt 0 ]
118118do
119- case $1 in
119+ case " $1 " in
120120-h|--help|-\? )
121121echo " $help "
122122exit 0
127127 ;;
128128-D)
129129shift
130- PGDATA=" $1 "
130+ # pass environment into new postmaster
131+ export PGDATA=" $1 "
131132 ;;
132133-l)
133- logfile=$2
134+ logfile=" $2 "
134135shift ;;
135136-l* )
136137 logfile=` echo" $1 " | sed' s/^-l//' `
137138 ;;
138139-m)
139- shutdown_mode=$2
140+ shutdown_mode=" $2 "
140141shift ;;
141142-m* )
142143 shutdown_mode=` echo" $1 " | sed' s/^-m//' `
@@ -197,15 +198,15 @@ if [ -z "$PGDATA" ];then
197198fi
198199
199200if [-z " $wait " ]; then
200- case $op in
201+ case " $op " in
201202start) wait=no;;
202203stop) wait=yes;;
203204restart) wait=no;;# must wait on shutdown anyhow
204205esac
205206fi
206207
207208
208- case $shutdown_mode in
209+ case " $shutdown_mode " in
209210 s|smart)
210211sig=" -TERM"
211212;;
@@ -227,7 +228,7 @@ DEFPOSTOPTS=$PGDATA/postmaster.opts.default
227228POSTOPTSFILE=$PGDATA /postmaster.opts
228229PIDFILE=$PGDATA /postmaster.pid
229230
230- if [$op = " status" ]; then
231+ if [" $op " = " status" ]; then
231232if [-f $PIDFILE ]; then
232233PID=` sed -n 1p$PIDFILE `
233234if [$PID -lt 0 ]; then
@@ -245,7 +246,7 @@ if [ $op = "status" ];then
245246fi
246247fi
247248
248- if [$op = " stop" -o $op = " restart" ]; then
249+ if [" $op " = " stop" -o " $op " = " restart" ]; then
249250if [-f $PIDFILE ]; then
250251PID=` sed -n 1p$PIDFILE `
251252if [$PID -lt 0 ]; then
@@ -255,7 +256,7 @@ if [ $op = "stop" -o $op = "restart" ];then
255256exit 1
256257fi
257258
258- kill $sig $PID
259+ kill " $sig " $PID
259260
260261# wait for postmaster to shut down
261262if [" $wait " = yes-o " $op " = restart ]; then
@@ -284,15 +285,15 @@ if [ $op = "stop" -o $op = "restart" ];then
284285else # ! -f $PIDFILE
285286echo " $CMDNAME : cannot find$PIDFILE " 1>&2
286287echo " Is postmaster running?" 1>&2
287- if [$op = " restart" ]; then
288+ if [" $op " = " restart" ]; then
288289echo " starting postmaster anyway" 1>&2
289290else
290291exit 1
291292fi
292293fi
293294fi # stop or restart
294295
295- if [$op = " start" -o $op = " restart" ]; then
296+ if [" $op " = " start" -o " $op " = " restart" ]; then
296297 oldpid=" "
297298if [-f $PIDFILE ]; then
298299echo " $CMDNAME : Another postmaster may be running. Trying to start postmaster anyway." 1>&2
@@ -301,24 +302,21 @@ if [ $op = "start" -o $op = "restart" ];then
301302
302303# no -o given
303304if [-z " $POSTOPTS " ]; then
304- if [$op = " start" ]; then
305+ if [" $op " = " start" ]; then
305306# if we are in start mode, then look for postmaster.opts.default
306307if [-f $DEFPOSTOPTS ]; then
307308eval set X" ` cat$DEFPOSTOPTS ` " ; shift
308309fi
309310else
310311# if we are in restart mode, then look for postmaster.opts
311312eval set X" ` cat$POSTOPTSFILE ` " ; shift
312- po_path=$1
313+ po_path=" $1 "
313314shift
314315fi
315316else # -o given
316317eval set X" $POSTOPTS " ; shift
317318fi
318319
319- # pass environment into new postmaster
320- export PGDATA
321-
322320if [-n " $logfile " ]; then
323321" $po_path " " $@ " < /dev/null>> $logfile 2>&1 &
324322else