Thread: Patch to put double quotes around all env variable tests in pg_ctl

Patch to put double quotes around all env variable tests in pg_ctl

From
Justin Clift
Date:
Hi Bruce,

This is a simple patch to put double quotes around a few cases in
pg_ctl.sh which were unquoted when inside of [].

This is against current CVS as of a few hours ago.

Regards and best wishes,

Justin Clift

--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi*** pg_ctl.sh.old    Sun Sep 23 11:49:17 2001
--- pg_ctl.sh    Sun Sep 23 12:11:24 2001
***************
*** 238,246 ****
  PIDFILE=$PGDATA/postmaster.pid

  if [ "$op" = "status" ];then
!     if [ -f $PIDFILE ];then
      PID=`sed -n 1p $PIDFILE`
!     if [ $PID -lt 0 ];then
          PID=`expr 0 - $PID`
          echo "$CMDNAME: postgres is running (pid: $PID)"
      else
--- 238,246 ----
  PIDFILE=$PGDATA/postmaster.pid

  if [ "$op" = "status" ];then
!     if [ -f "$PIDFILE" ];then
      PID=`sed -n 1p $PIDFILE`
!     if [ "$PID" -lt 0 ];then
          PID=`expr 0 - $PID`
          echo "$CMDNAME: postgres is running (pid: $PID)"
      else
***************
*** 256,264 ****
  fi

  if [ "$op" = "stop" -o "$op" = "restart" -o "$op" = "reload" ];then
!     if [ -f $PIDFILE ];then
      PID=`sed -n 1p $PIDFILE`
!     if [ $PID -lt 0 ];then
          PID=`expr 0 - $PID`
          echo "$CMDNAME: Cannot restart postmaster.  postgres is running (pid: $PID)" 1>&2
          echo "Please terminate postgres and try again." 1>&2
--- 256,264 ----
  fi

  if [ "$op" = "stop" -o "$op" = "restart" -o "$op" = "reload" ];then
!     if [ -f "$PIDFILE" ];then
      PID=`sed -n 1p $PIDFILE`
!     if [ "$PID" -lt 0 ];then
          PID=`expr 0 - $PID`
          echo "$CMDNAME: Cannot restart postmaster.  postgres is running (pid: $PID)" 1>&2
          echo "Please terminate postgres and try again." 1>&2
***************
*** 274,283 ****

          while :
          do
!         if [ -f $PIDFILE ];then
              $silence_echo $ECHO_N "."$ECHO_C
              cnt=`expr $cnt + 1`
!             if [ $cnt -gt $wait_seconds ];then
              $silence_echo echo " failed"
              echo "$CMDNAME: postmaster does not shut down" 1>&2
              exit 1
--- 274,283 ----

          while :
          do
!         if [ -f "$PIDFILE" ];then
              $silence_echo $ECHO_N "."$ECHO_C
              cnt=`expr $cnt + 1`
!             if [ "$cnt" -gt "$wait_seconds" ];then
              $silence_echo echo " failed"
              echo "$CMDNAME: postmaster does not shut down" 1>&2
              exit 1
***************
*** 309,315 ****

  if [ "$op" = "start" -o "$op" = "restart" ];then
      oldpid=""
!     if [ -f $PIDFILE ];then
      echo "$CMDNAME: Another postmaster may be running.  Trying to start postmaster anyway." 1>&2
      oldpid=`sed -n 1p $PIDFILE`
      fi
--- 309,315 ----

  if [ "$op" = "start" -o "$op" = "restart" ];then
      oldpid=""
!     if [ -f "$PIDFILE" ];then
      echo "$CMDNAME: Another postmaster may be running.  Trying to start postmaster anyway." 1>&2
      oldpid=`sed -n 1p $PIDFILE`
      fi
***************
*** 318,324 ****
      if [ -z "$POSTOPTS" ];then
      if [ "$op" = "start" ];then
          # if we are in start mode, then look for postmaster.opts.default
!         if [ -f $DEFPOSTOPTS ]; then
          eval set X "`cat $DEFPOSTOPTS`"; shift
          fi
      else
--- 318,324 ----
      if [ -z "$POSTOPTS" ];then
      if [ "$op" = "start" ];then
          # if we are in start mode, then look for postmaster.opts.default
!         if [ -f "$DEFPOSTOPTS" ]; then
          eval set X "`cat $DEFPOSTOPTS`"; shift
          fi
      else
***************
*** 343,349 ****
      # if had an old lockfile, check to see if we were able to start
      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
--- 343,349 ----
      # if had an old lockfile, check to see if we were able to start
      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
***************
*** 376,382 ****
          else
          $silence_echo $ECHO_N "."$ECHO_C
          cnt=`expr $cnt + 1`
!         if [ $cnt -gt $wait_seconds ];then
              $silence_echo echo "failed"
              echo "$CMDNAME: postmaster does not start" 1>&2
              exit 1
--- 376,382 ----
          else
          $silence_echo $ECHO_N "."$ECHO_C
          cnt=`expr $cnt + 1`
!         if [ "$cnt" -gt "$wait_seconds" ];then
              $silence_echo echo "failed"
              echo "$CMDNAME: postmaster does not start" 1>&2
              exit 1

Re: Patch to put double quotes around all env variable tests

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> Hi Bruce,
>
> This is a simple patch to put double quotes around a few cases in
> pg_ctl.sh which were unquoted when inside of [].
>
> This is against current CVS as of a few hours ago.
>
> Regards and best wishes,
>
> Justin Clift
>
> --
> "My grandfather once told me that there are two kinds of people: those
> who work and those who take the credit. He told me to try to be in the
> first group; there was less competition there."
>      - Indira Gandhi

> *** pg_ctl.sh.old    Sun Sep 23 11:49:17 2001
> --- pg_ctl.sh    Sun Sep 23 12:11:24 2001
> ***************
> *** 238,246 ****
>   PIDFILE=$PGDATA/postmaster.pid
>
>   if [ "$op" = "status" ];then
> !     if [ -f $PIDFILE ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ $PID -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: postgres is running (pid: $PID)"
>       else
> --- 238,246 ----
>   PIDFILE=$PGDATA/postmaster.pid
>
>   if [ "$op" = "status" ];then
> !     if [ -f "$PIDFILE" ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ "$PID" -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: postgres is running (pid: $PID)"
>       else
> ***************
> *** 256,264 ****
>   fi
>
>   if [ "$op" = "stop" -o "$op" = "restart" -o "$op" = "reload" ];then
> !     if [ -f $PIDFILE ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ $PID -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: Cannot restart postmaster.  postgres is running (pid: $PID)" 1>&2
>           echo "Please terminate postgres and try again." 1>&2
> --- 256,264 ----
>   fi
>
>   if [ "$op" = "stop" -o "$op" = "restart" -o "$op" = "reload" ];then
> !     if [ -f "$PIDFILE" ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ "$PID" -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: Cannot restart postmaster.  postgres is running (pid: $PID)" 1>&2
>           echo "Please terminate postgres and try again." 1>&2
> ***************
> *** 274,283 ****
>
>           while :
>           do
> !         if [ -f $PIDFILE ];then
>               $silence_echo $ECHO_N "."$ECHO_C
>               cnt=`expr $cnt + 1`
> !             if [ $cnt -gt $wait_seconds ];then
>               $silence_echo echo " failed"
>               echo "$CMDNAME: postmaster does not shut down" 1>&2
>               exit 1
> --- 274,283 ----
>
>           while :
>           do
> !         if [ -f "$PIDFILE" ];then
>               $silence_echo $ECHO_N "."$ECHO_C
>               cnt=`expr $cnt + 1`
> !             if [ "$cnt" -gt "$wait_seconds" ];then
>               $silence_echo echo " failed"
>               echo "$CMDNAME: postmaster does not shut down" 1>&2
>               exit 1
> ***************
> *** 309,315 ****
>
>   if [ "$op" = "start" -o "$op" = "restart" ];then
>       oldpid=""
> !     if [ -f $PIDFILE ];then
>       echo "$CMDNAME: Another postmaster may be running.  Trying to start postmaster anyway." 1>&2
>       oldpid=`sed -n 1p $PIDFILE`
>       fi
> --- 309,315 ----
>
>   if [ "$op" = "start" -o "$op" = "restart" ];then
>       oldpid=""
> !     if [ -f "$PIDFILE" ];then
>       echo "$CMDNAME: Another postmaster may be running.  Trying to start postmaster anyway." 1>&2
>       oldpid=`sed -n 1p $PIDFILE`
>       fi
> ***************
> *** 318,324 ****
>       if [ -z "$POSTOPTS" ];then
>       if [ "$op" = "start" ];then
>           # if we are in start mode, then look for postmaster.opts.default
> !         if [ -f $DEFPOSTOPTS ]; then
>           eval set X "`cat $DEFPOSTOPTS`"; shift
>           fi
>       else
> --- 318,324 ----
>       if [ -z "$POSTOPTS" ];then
>       if [ "$op" = "start" ];then
>           # if we are in start mode, then look for postmaster.opts.default
> !         if [ -f "$DEFPOSTOPTS" ]; then
>           eval set X "`cat $DEFPOSTOPTS`"; shift
>           fi
>       else
> ***************
> *** 343,349 ****
>       # if had an old lockfile, check to see if we were able to start
>       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
> --- 343,349 ----
>       # if had an old lockfile, check to see if we were able to start
>       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
> ***************
> *** 376,382 ****
>           else
>           $silence_echo $ECHO_N "."$ECHO_C
>           cnt=`expr $cnt + 1`
> !         if [ $cnt -gt $wait_seconds ];then
>               $silence_echo echo "failed"
>               echo "$CMDNAME: postmaster does not start" 1>&2
>               exit 1
> --- 376,382 ----
>           else
>           $silence_echo $ECHO_N "."$ECHO_C
>           cnt=`expr $cnt + 1`
> !         if [ "$cnt" -gt "$wait_seconds" ];then
>               $silence_echo echo "failed"
>               echo "$CMDNAME: postmaster does not start" 1>&2
>               exit 1

>
> ---------------------------(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@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: Patch to put double quotes around all env variable tests

From
Bruce Momjian
Date:
Patch applied.  Thanks.

> Hi Bruce,
>
> This is a simple patch to put double quotes around a few cases in
> pg_ctl.sh which were unquoted when inside of [].
>
> This is against current CVS as of a few hours ago.
>
> Regards and best wishes,
>
> Justin Clift
>
> --
> "My grandfather once told me that there are two kinds of people: those
> who work and those who take the credit. He told me to try to be in the
> first group; there was less competition there."
>      - Indira Gandhi

> *** pg_ctl.sh.old    Sun Sep 23 11:49:17 2001
> --- pg_ctl.sh    Sun Sep 23 12:11:24 2001
> ***************
> *** 238,246 ****
>   PIDFILE=$PGDATA/postmaster.pid
>
>   if [ "$op" = "status" ];then
> !     if [ -f $PIDFILE ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ $PID -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: postgres is running (pid: $PID)"
>       else
> --- 238,246 ----
>   PIDFILE=$PGDATA/postmaster.pid
>
>   if [ "$op" = "status" ];then
> !     if [ -f "$PIDFILE" ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ "$PID" -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: postgres is running (pid: $PID)"
>       else
> ***************
> *** 256,264 ****
>   fi
>
>   if [ "$op" = "stop" -o "$op" = "restart" -o "$op" = "reload" ];then
> !     if [ -f $PIDFILE ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ $PID -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: Cannot restart postmaster.  postgres is running (pid: $PID)" 1>&2
>           echo "Please terminate postgres and try again." 1>&2
> --- 256,264 ----
>   fi
>
>   if [ "$op" = "stop" -o "$op" = "restart" -o "$op" = "reload" ];then
> !     if [ -f "$PIDFILE" ];then
>       PID=`sed -n 1p $PIDFILE`
> !     if [ "$PID" -lt 0 ];then
>           PID=`expr 0 - $PID`
>           echo "$CMDNAME: Cannot restart postmaster.  postgres is running (pid: $PID)" 1>&2
>           echo "Please terminate postgres and try again." 1>&2
> ***************
> *** 274,283 ****
>
>           while :
>           do
> !         if [ -f $PIDFILE ];then
>               $silence_echo $ECHO_N "."$ECHO_C
>               cnt=`expr $cnt + 1`
> !             if [ $cnt -gt $wait_seconds ];then
>               $silence_echo echo " failed"
>               echo "$CMDNAME: postmaster does not shut down" 1>&2
>               exit 1
> --- 274,283 ----
>
>           while :
>           do
> !         if [ -f "$PIDFILE" ];then
>               $silence_echo $ECHO_N "."$ECHO_C
>               cnt=`expr $cnt + 1`
> !             if [ "$cnt" -gt "$wait_seconds" ];then
>               $silence_echo echo " failed"
>               echo "$CMDNAME: postmaster does not shut down" 1>&2
>               exit 1
> ***************
> *** 309,315 ****
>
>   if [ "$op" = "start" -o "$op" = "restart" ];then
>       oldpid=""
> !     if [ -f $PIDFILE ];then
>       echo "$CMDNAME: Another postmaster may be running.  Trying to start postmaster anyway." 1>&2
>       oldpid=`sed -n 1p $PIDFILE`
>       fi
> --- 309,315 ----
>
>   if [ "$op" = "start" -o "$op" = "restart" ];then
>       oldpid=""
> !     if [ -f "$PIDFILE" ];then
>       echo "$CMDNAME: Another postmaster may be running.  Trying to start postmaster anyway." 1>&2
>       oldpid=`sed -n 1p $PIDFILE`
>       fi
> ***************
> *** 318,324 ****
>       if [ -z "$POSTOPTS" ];then
>       if [ "$op" = "start" ];then
>           # if we are in start mode, then look for postmaster.opts.default
> !         if [ -f $DEFPOSTOPTS ]; then
>           eval set X "`cat $DEFPOSTOPTS`"; shift
>           fi
>       else
> --- 318,324 ----
>       if [ -z "$POSTOPTS" ];then
>       if [ "$op" = "start" ];then
>           # if we are in start mode, then look for postmaster.opts.default
> !         if [ -f "$DEFPOSTOPTS" ]; then
>           eval set X "`cat $DEFPOSTOPTS`"; shift
>           fi
>       else
> ***************
> *** 343,349 ****
>       # if had an old lockfile, check to see if we were able to start
>       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
> --- 343,349 ----
>       # if had an old lockfile, check to see if we were able to start
>       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
> ***************
> *** 376,382 ****
>           else
>           $silence_echo $ECHO_N "."$ECHO_C
>           cnt=`expr $cnt + 1`
> !         if [ $cnt -gt $wait_seconds ];then
>               $silence_echo echo "failed"
>               echo "$CMDNAME: postmaster does not start" 1>&2
>               exit 1
> --- 376,382 ----
>           else
>           $silence_echo $ECHO_N "."$ECHO_C
>           cnt=`expr $cnt + 1`
> !         if [ "$cnt" -gt "$wait_seconds" ];then
>               $silence_echo echo "failed"
>               echo "$CMDNAME: postmaster does not start" 1>&2
>               exit 1

>
> ---------------------------(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@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026