pg_ctl failure with older Bourne shells (use ${1:+"$@"})

From: Mike Coleman <mkc(at)stowers-institute(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Cc: mkc(at)mathdogs(dot)com
Subject: pg_ctl failure with older Bourne shells (use ${1:+"$@"})
Date: 2002-07-18 20:12:20
Message-ID: 200207182012.PAA0000440546@gskc01.stowers-institute.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Your name : Mike Coleman
Your email address : mkc(at)mathdogs(dot)com

System Configuration
---------------------
Architecture (example: Intel Pentium) :alpha

Operating System (example: Linux 2.0.26 ELF) :Tru64 5.1

PostgreSQL version (example: PostgreSQL-7.2.1): PostgreSQL-7.2.1

Compiler used (example: gcc 2.95.2) :gcc 3.1

Please enter a FULL description of your problem:
------------------------------------------------

The pg_ctl script uses the "$@" construct. Newer shells will replace
this with nothing if $@ is empty, but older shells will not. The
alternate form in the patch below will work for both new and old
shells.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

The problem occurs with this command, for example:

$ /usr/local/pgsql/bin/pg_ctl -D /data1/postgres-0 -l logfile start

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

--- /usr/local/pgsql/bin/pg_ctl.dist 2002-07-18 11:34:25.000000000 -0500
+++ /usr/local/pgsql/bin/pg_ctl 2002-07-18 14:44:35.000000000 -0500
@@ -332,12 +332,12 @@
fi

if [ -n "$logfile" ]; then
- "$po_path" "$@" </dev/null >>$logfile 2>&1 &
+ "$po_path" ${1:+"$@"} </dev/null >>$logfile 2>&1 &
else
# when starting without log file, redirect stderr to stdout, so
# pg_ctl can be invoked with >$logfile and still have pg_ctl's
# stderr on the terminal.
- "$po_path" "$@" </dev/null 2>&1 &
+ "$po_path" ${1:+"$@"} </dev/null 2>&1 &
fi

# if had an old lockfile, check to see if we were able to start

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2002-07-19 00:27:12 Bug #714: pg_dump segfaults when given an invalid command line option
Previous Message Stephan Szabo 2002-07-18 15:36:33 Re: Behaviour