Skip site navigation (1) Skip section navigation (2)

Re: Patch to pg_ctl to better support paths containing

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Barry Lind <barry(at)xythos(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Patch to pg_ctl to better support paths containing
Date: 2001-09-22 04:24:45
Message-ID: 200109220424.f8M4Oji26347@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
Sorry, for some reason my email reader did not group these together. 
Removed from patch queue.

> Barry Lind writes:
> 
> > Attached is a set of changes to pg_ctl that I have been using that fixes
> > problems I have had with pg_ctl when the paths contains spaces.
> 
> > ! CMDNAME=`basename "$0"`
> 
> OK.
> 
> >   else
> >           # look for it in PATH ('which' command is not portable)
> > !         for dir in `echo "$PATH" | sed 's/ /\\\_/g' | sed 's/:/ /g'`
> >   	do
> > +                 dir="`echo $dir | sed 's/\\\_/ /g'`"
> >                   # empty entry in path means current dir
> >                   [ -z "$dir" ] && dir='.'
> 
> Probably better to do this with IFS.  Btw., this piece of code exists in
> identical form in most other PostgreSQL shell scripts.  Do you intend to
> fix those as well?
> 
> > ! DEFPOSTOPTS="$PGDATA/postmaster.opts.default"
> > ! POSTOPTSFILE="$PGDATA/postmaster.opts"
> > ! PIDFILE="$PGDATA/postmaster.pid"
> 
> This is not necessary.
> 
> >   if [ "$op" = "status" ];then
> > !     if [ -f "$PIDFILE" ];then
> > ! 	PID=`sed -n 1p "$PIDFILE"`
> >   	if [ $PID -lt 0 ];then
> 
> ... more similar stuff OK ...
> 
> >   	else
> >   	    # if we are in restart mode, then look for postmaster.opts
> > ! 	    eval set X "`cat "$POSTOPTSFILE"`"; shift
> >               po_path="$1"
> 
> That is not portable.  There is no portable way to have double quotes
> within backticks within double quotes.  You might be able to do something
> along the lines of
> 
>     foo=`cat "$POSTOPTSFILE"`
>     eval set X "$foo"; shift
> 
> The expression in question was carefully engineered to handle single
> quotes and spaces in the POSTOPTSFILE correctly, so be careful. ;-)
> 
> >       if [ -n "$oldpid" ];then
> >   	sleep 1
> > ! 	if [ -f "$PIDFILE" ];then
> > ! 	    if [ "`sed -n 1p "$PIDFILE"`" = "$oldpid" ];then
> >   		echo "$CMDNAME: cannot start postmaster" 1>&2
> >   		echo "Examine the log output." 1>&2
> 
> Same problem here.
> 
> -- 
> Peter Eisentraut   peter_e(at)gmx(dot)net   http://funkturm.homeip.net/~peter
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to

pgsql-patches by date

Next:From: Bruce MomjianDate: 2001-09-22 04:27:49
Subject: Re: Patch to pg_ctl to better support paths containing
Previous:From: Bruce MomjianDate: 2001-09-22 04:22:55
Subject: Re: Patch to pg_ctl to better support paths containing spaces

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group