Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e41e0fc

Browse files
committed
Move export PGDATA to the proper place. Quote some variable substitutions.
1 parent 443db06 commit e41e0fc

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/bin/pg_ctl/pg_ctl.sh

+16-18
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010
# IDENTIFICATION
11-
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.21 2001/07/11 04:57:34 momjian Exp $
11+
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.22 2001/07/11 16:16:52 momjian Exp $
1212
#
1313
#-------------------------------------------------------------------------
1414

@@ -79,7 +79,7 @@ fi
7979
if echo "$0" | grep '/' > /dev/null 2>&1
8080
then
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)
8383
else
8484
# look for it in PATH ('which' command is not portable)
8585
for dir in `echo "$PATH" | sed 's/:/ /g'`
@@ -116,7 +116,7 @@ shutdown_mode=smart
116116

117117
while [ "$#" -gt 0 ]
118118
do
119-
case $1 in
119+
case "$1" in
120120
-h|--help|-\?)
121121
echo "$help"
122122
exit 0
@@ -127,16 +127,17 @@ do
127127
;;
128128
-D)
129129
shift
130-
PGDATA="$1"
130+
# pass environment into new postmaster
131+
export PGDATA="$1"
131132
;;
132133
-l)
133-
logfile=$2
134+
logfile="$2"
134135
shift;;
135136
-l*)
136137
logfile=`echo "$1" | sed 's/^-l//'`
137138
;;
138139
-m)
139-
shutdown_mode=$2
140+
shutdown_mode="$2"
140141
shift;;
141142
-m*)
142143
shutdown_mode=`echo "$1" | sed 's/^-m//'`
@@ -197,15 +198,15 @@ if [ -z "$PGDATA" ];then
197198
fi
198199

199200
if [ -z "$wait" ]; then
200-
case $op in
201+
case "$op" in
201202
start) wait=no;;
202203
stop) wait=yes;;
203204
restart) wait=no;; # must wait on shutdown anyhow
204205
esac
205206
fi
206207

207208

208-
case $shutdown_mode in
209+
case "$shutdown_mode" in
209210
s|smart)
210211
sig="-TERM"
211212
;;
@@ -227,7 +228,7 @@ DEFPOSTOPTS=$PGDATA/postmaster.opts.default
227228
POSTOPTSFILE=$PGDATA/postmaster.opts
228229
PIDFILE=$PGDATA/postmaster.pid
229230

230-
if [ $op = "status" ];then
231+
if [ "$op" = "status" ];then
231232
if [ -f $PIDFILE ];then
232233
PID=`sed -n 1p $PIDFILE`
233234
if [ $PID -lt 0 ];then
@@ -245,7 +246,7 @@ if [ $op = "status" ];then
245246
fi
246247
fi
247248

248-
if [ $op = "stop" -o $op = "restart" ];then
249+
if [ "$op" = "stop" -o "$op" = "restart" ];then
249250
if [ -f $PIDFILE ];then
250251
PID=`sed -n 1p $PIDFILE`
251252
if [ $PID -lt 0 ];then
@@ -255,7 +256,7 @@ if [ $op = "stop" -o $op = "restart" ];then
255256
exit 1
256257
fi
257258

258-
kill $sig $PID
259+
kill "$sig" $PID
259260

260261
# wait for postmaster to shut down
261262
if [ "$wait" = yes -o "$op" = restart ];then
@@ -284,15 +285,15 @@ if [ $op = "stop" -o $op = "restart" ];then
284285
else # ! -f $PIDFILE
285286
echo "$CMDNAME: cannot find $PIDFILE" 1>&2
286287
echo "Is postmaster running?" 1>&2
287-
if [ $op = "restart" ];then
288+
if [ "$op" = "restart" ];then
288289
echo "starting postmaster anyway" 1>&2
289290
else
290291
exit 1
291292
fi
292293
fi
293294
fi # stop or restart
294295

295-
if [ $op = "start" -o $op = "restart" ];then
296+
if [ "$op" = "start" -o "$op" = "restart" ];then
296297
oldpid=""
297298
if [ -f $PIDFILE ];then
298299
echo "$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
303304
if [ -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
306307
if [ -f $DEFPOSTOPTS ]; then
307308
eval set X "`cat $DEFPOSTOPTS`"; shift
308309
fi
309310
else
310311
# if we are in restart mode, then look for postmaster.opts
311312
eval set X "`cat $POSTOPTSFILE`"; shift
312-
po_path=$1
313+
po_path="$1"
313314
shift
314315
fi
315316
else # -o given
316317
eval set X "$POSTOPTS"; shift
317318
fi
318319

319-
# pass environment into new postmaster
320-
export PGDATA
321-
322320
if [ -n "$logfile" ]; then
323321
"$po_path" "$@" </dev/null >>$logfile 2>&1 &
324322
else

0 commit comments

Comments
 (0)