[Toybox] Mutually Exclusive Arguments. Bug?
briggers at ninthfloor.org
briggers at ninthfloor.org
Sun Jun 3 06:07:39 PDT 2012
Hi,
I was trying to use the ~ control character to implement mutually
exclusive option arguments.
pwd takes two options -P and -L, which are mutually exclusive. Using the ~
control character the optstring should be "L~PP~L". Using this optstring
gives a "Segmentation fault (core dumped)" error when running the pwd
command.
For optstring "LP~L" the command runs. But since the command line
arguments are parsed from left to right "-L -P" results in an optflag
value of 1, and "-P -L" gives an optflag value of 3. Since the options are
mutually exclusive, the optflag value should be either 1 or 2 (or 0 incase
of no arguments)
optstring "L~PP" also gives "Segmentation fault (core dumped)" error.
It seems disabling an option before it is even defined in the optstring is
the cause for the segmentation fault. I'm not sure if this is intentional
or not.
I'm at a loss at trying to implement order independent argument exclusion
without using ~. Ideas, suggestions?
--
Ashish Bhate
1338728859.0
More information about the Toybox
mailing list