In some parts of the code, the optional argument handling is missing
for cases where the argument starts with '='. This is particularly
important for short options with optional arguments, as suggested by
our man pages. The libc getopt_long() handles this for long options,
but for short options, it's our responsibility.
Note that some argument parsing functions (mostly colormode_or_err())
already implement this, as they are usually used with optional
arguments.
Signed-off-by: Karel Zak <kzak@redhat.com>
const char *subexpr = NULL;
ctl.sockets_only = 1;
+ if (optarg && *optarg == '=')
+ optarg++;
if (optarg == NULL)
subexpr = inet46_subexpr;
else if (strcmp(optarg, "4") == 0)
return EXIT_SUCCESS;
case 'd':
if (optarg) {
+ if (*optarg == '=')
+ optarg++;
dump = fopen(optarg, "w");
if (!dump)
err(EXIT_FAILURE, _("Could not open %s"), optarg);
err_exclusive_options(c, longopts, excl, excl_st);
switch (c) {
case 'C':
- if (optarg != NULL)
+ if (optarg) {
+ if (*optarg == '=')
+ optarg++;
uuidd_cxt->cont_clock_offset = parse_cont_clock(optarg);
- else
+ } else
uuidd_cxt->cont_clock_offset = 7200; /* default 2h */
break;
case 'd':
break;
case 'b':
if (optarg) {
+ if (*optarg == '=')
+ optarg++;
ctl.backup = optarg;
} else {
ctl.backup = getenv("HOME");
case 'a':
rm_all = 1;
if (optarg) {
+ if (*optarg == '=')
+ optarg++;
if (!strcmp(optarg, "shm"))
what_all = SHM;
else if (!strcmp(optarg, "pshm"))
{
struct namespace_file *nsfile = get_nsfile(nstype);
- if (nsfile)
+ if (nsfile) {
+ if (path && *path == '=') /* used in getopt_long() block */
+ path++;
enable_nsfile(nsfile, path);
- else
+ } else
assert(nsfile);
}
do_rd = true;
break;
case 'w':
- if (optarg)
+ if (optarg) {
+ if (*optarg == '=')
+ optarg++;
open_target_fd(&wd_fd, "cwd", optarg);
- else
+ } else
do_wd = true;
break;
case 'W':
+ if (optarg && *optarg == '=')
+ optarg++;
wdns = optarg;
break;
case 'e':