Re: [PATCH v3 1/5] parse-options: Allow PARSE_OPT_NOARG in integer arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Junio,

Junio C Hamano writes:
> Ramkumar Ramachandra <artagnon@xxxxxxxxx> writes:
> 
> > When the option parser encounters an OPTION_INTEGER argument,
> > PARSE_OPT_NOARG should imply that the default value should be used.
> 
> Sorry but why?
> 
> Doesn't NOARG mean "Do not take an argument, if you give me an argument
> that is an error"?

Oh, does it mean that? I might have interpreted the description in
`parse-options.h` too literally: "says that this option takes no
argument". So I'm handling the case when an integer option is
specified, but no integer argument is given.

> I would understand if this were OPT_OPTARG, though.

That case is already handled. The condition (opt->flags & PARSE_OPT_OPTARG &&
!p->opt) does the same thing.

> Confused...

Okay, let me explain. Let's say I want to have an option that takes an
integer argument, say `foo`. To set it to the integer argument 42, I
can say `--foo=42`. To set it to its default value, I could earlier
say `--foo=`. With this patch I can simply say `--foo`. Makes sense?

-- Ram
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]