Command-line parsing in pg_ctl is not portable

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Command-line parsing in pg_ctl is not portable
Date: 2004-10-19 13:50:37
Message-ID: 200410191550.37098.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The command-line argument parsing in pg_ctl is not portable. This is the
output on a glibc system:

$ pg_ctl start stop
pg_ctl: too many command-line arguments (first is "start")

But:

$ POSIXLY_CORRECT=1 pg_ctl start stop
pg_ctl: too many command-line arguments (first is "stop")

This is probably because GNU getopt rearranges the arguments, and since pg_ctl
uses two while loops to try to allow non-option arguments before options,
things may get reordered multiple times.

Now this particular case is minor trouble, but I wonder in what other
situations arguments will get reordered where the order does make a
difference.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas DAZ SD 2004-10-19 14:09:17 Re: [PATCHES] Open Items
Previous Message Alvaro Herrera 2004-10-19 13:02:13 Re: 7.4 changes