mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
Fix repmgrd's command line help option parsing
As in commit d0c05e6f46, properly distinguish between
the command line option -? and getopt's unknown option marker '?'
This commit is contained in:
27
repmgrd.c
27
repmgrd.c
@@ -124,7 +124,7 @@ main(int argc, char **argv)
|
|||||||
{"monitoring-history", no_argument, NULL, 'm'},
|
{"monitoring-history", no_argument, NULL, 'm'},
|
||||||
{"daemonize", no_argument, NULL, 'd'},
|
{"daemonize", no_argument, NULL, 'd'},
|
||||||
{"pid-file", required_argument, NULL, 'p'},
|
{"pid-file", required_argument, NULL, 'p'},
|
||||||
{"help", no_argument, NULL, '?'},
|
{"help", no_argument, NULL, OPT_HELP},
|
||||||
{"version", no_argument, NULL, 'V'},
|
{"version", no_argument, NULL, 'V'},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
@@ -158,6 +158,23 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case '?':
|
||||||
|
/* Actual help option given */
|
||||||
|
if (strcmp(argv[optind - 1], "-?") == 0)
|
||||||
|
{
|
||||||
|
help();
|
||||||
|
exit(SUCCESS);
|
||||||
|
}
|
||||||
|
/* unknown option reported by getopt */
|
||||||
|
else
|
||||||
|
goto unknown_option;
|
||||||
|
break;
|
||||||
|
case OPT_HELP:
|
||||||
|
help();
|
||||||
|
exit(SUCCESS);
|
||||||
|
case 'V':
|
||||||
|
printf("%s %s (PostgreSQL %s)\n", progname(), REPMGR_VERSION, PG_VERSION);
|
||||||
|
exit(SUCCESS);
|
||||||
case 'f':
|
case 'f':
|
||||||
config_file = optarg;
|
config_file = optarg;
|
||||||
break;
|
break;
|
||||||
@@ -173,13 +190,9 @@ main(int argc, char **argv)
|
|||||||
case 'p':
|
case 'p':
|
||||||
pid_file = optarg;
|
pid_file = optarg;
|
||||||
break;
|
break;
|
||||||
case '?':
|
|
||||||
help();
|
|
||||||
exit(SUCCESS);
|
|
||||||
case 'V':
|
|
||||||
printf("%s %s (PostgreSQL %s)\n", progname(), REPMGR_VERSION, PG_VERSION);
|
|
||||||
exit(SUCCESS);
|
|
||||||
default:
|
default:
|
||||||
|
unknown_option:
|
||||||
usage();
|
usage();
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user