Patch for afsutils and getarg
Chris Wing
wingc at engin.umich.edu
Wed Nov 3 09:31:57 CET 1999
Hi. I downloaded the Arla code from CVS today and started playing with
getting klog, tokens, and unlog working properly with getarg(). I fixed a
few minor problems, but ultimately discovered that I couldn't get them to
work right without some changes to getarg() itself.
This patch:
http://www.engin.umich.edu/caen/systems/Linux/code/patches/arla-afsutils_and_getarg.patch
contains fixes to klog, tokens, and unlog, which makes them all use the
getarg() function and still work as before.
It also contains the following changes to getarg():
- changes for better pretty printing of the options in arg_printusage():
- display ... within [] for arg_strings
- display [-long, -s] for an argument with long and short names
- display arg_generic options without long or short names
(see below)
- allow the short name to also match for an argument which has a long
name. This means that:
tokens -v
or
tokens -verbose
will both give a verbose output, and
tokens -version
will work properly too.
(previously, 'tokens -v' would be discarded as ambiguous between
-verbose and -version)
- implement arg_generic_string and arg_generic_strings, which match any
element of argv which does not match any of the other arguments. This
is needed so that I can do:
klog wingc
klog -tmp wingc
or
klog wingc -tmp
(an arg_generic_string matches 'wingc' in any of the above locations)
likewise, in
unlog cell1.edu cell2.edu
'cell1.edu cell2.edu' matches an arg_generic_strings.
A problem that I came across is that the existing code which calls
getarg assumes that arguments can be given without a flag.
(i.e. 'pts examine wingc'). This breaks the use of arg_generic types,
because, according to this behavior:
klog wingc
'wingc' will be interpreted as matching the first argument in the list
of getargs no matter what.
(in this case, the first argument is "principal", so
klog wingc
is somewhat meaningful, it parses as:
klog wingc at your.local.cell
but
klog wingc at umich.edu
parses as:
klog wingc at umich.edu@your.local.cell
which doesn't make any sense)
The above patch changes the behavior of getarg so that arguments cannot
match without being given a flag, _unless_ they are defined as
arg_mandatory. (which seems to be the case for the existing arla code in
pts.c and elsewhere, but I haven't done an absolutely thorough check)
In summary: the existing behavior of getarg (allowing arguments to be
given without the flag), will be preserved as long as the arguments are
defined as arg_mandatory. Is this okay?
Thanks,
Chris Wing
wingc at engin.umich.edu
More information about the Arla-drinkers
mailing list