Re: pgbench: improve --help and --version parsing

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Andrei Korigodski <akorigod(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgbench: improve --help and --version parsing
Date: 2018-07-22 14:19:50
Message-ID: alpine.DEB.2.21.1807221003170.3848@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> Agreed. I have changed handling of the --help and --version options in all apps
> where it exhibits the problem described, with the exception for pg_archivecleanup
> where getopt is used instead of getopt_long. The separate patch will be proposed
> to address it.
>
> The patch is against current master. All tests pass.

I doubt that -V & -? are heavily tested:-) Patch works for me, though.

There seems to be other instances as well:

./src/interfaces/ecpg/preproc/ecpg.c: while ((c = getopt_long(argc, argv, "vcio:I:tD:dC:r:h", ecpg_options, NULL)) != -1)
./src/bin/scripts/clusterdb.c: while ((c = getopt_long(argc, argv, "h:p:U:wWeqd:at:v", long_options, &optindex)) != -1)
./src/bin/scripts/createdb.c: while ((c = getopt_long(argc, argv, "h:p:U:wWeO:D:T:E:l:", long_options, &optindex)) != -1)
./src/bin/scripts/dropuser.c: while ((c = getopt_long(argc, argv, "h:p:U:wWei", long_options, &optindex)) != -1)
./src/bin/scripts/pg_isready.c: while ((c = getopt_long(argc, argv, "d:h:p:qt:U:", long_options, NULL)) != -1)
./src/bin/scripts/dropdb.c: while ((c = getopt_long(argc, argv, "h:p:U:wWei", long_options, &optindex)) != -1)
./src/bin/scripts/vacuumdb.c: while ((c = getopt_long(argc, argv, "h:p:U:wWeqd:zZFat:fvj:", long_options, &optindex)) != -1)
./src/bin/scripts/createuser.c: while ((c = getopt_long(argc, argv, "h:p:U:g:wWedDsSaArRiIlLc:PE",
./src/bin/scripts/reindexdb.c: while ((c = getopt_long(argc, argv, "h:p:U:wWeqS:d:ast:i:v", long_options, &optindex)) != -1)

./src/interfaces/ecpg/preproc/ecpg.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
./src/timezone/zic.c: else if (strcmp(argv[k], "--help") == 0)
./src/backend/main/main.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
./src/bin/pg_archivecleanup/pg_archivecleanup.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
./src/bin/pg_upgrade/option.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
./src/bin/pg_ctl/pg_ctl.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
./src/bin/psql/startup.c: if ((strcmp(argv[1], "-?") == 0) || (argc == 2 && (strcmp(argv[1], "--help") == 0)))
./src/bin/scripts/common.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
=> implementation shared by many C "scripts".
./src/bin/pg_config/pg_config.c: if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
./contrib/oid2name/oid2name.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
./contrib/pg_standby/pg_standby.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
./contrib/vacuumlo/vacuumlo.c: if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-07-22 14:46:03 Re: Non-portable shell code in pg_upgrade tap tests
Previous Message Fabien COELHO 2018-07-22 13:56:08 Re: pgbench-ycsb