Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLD does not warn about ambiguous option #17

Open
dod38fr opened this issue Oct 21, 2015 · 3 comments
Open

GLD does not warn about ambiguous option #17

dod38fr opened this issue Oct 21, 2015 · 3 comments

Comments

@dod38fr
Copy link

dod38fr commented Oct 21, 2015

Hello

I have a set of options specified with:

   ...
      [ "force-load!"        => "Load file even if error are found in data. Bad data are discarded"],
      [ "file=s"             => "Specify a target file"],
   ...
    { getopt_conf => [ qw/no_bundling/ ] }

But GLD does not warn when command line is used with -f option. My program runs as if no option was specified. On the other hand -fi and -file options work as expected.

Getopt::Long has a different behavior: a warning message is shown to user when an option is ambiguous.

All the best

@dod38fr dod38fr changed the title GLD does not warn about ambiguoug options GLD does not warn about ambiguous option Oct 21, 2015
@n1vux
Copy link

n1vux commented Jan 7, 2016

Related, we have a script with several successive authors, in a GLD standardized project, that now has two options among many:

  [ "tab|t=i%" => ...
  ... many others ...
  [ "text|t" => ... some debug option rarely used ...

(Aside: Given that neither of these is what -t normally means in our scripts, so one might sensibly suggest neither should have had a default at all, but then I wouldn't have information to add here.)
It is not immediately clear if GLD set both the {tab} hash and the {text} flag, or just the flag, but it neither warned of the ambiguity, nor did resolve the ambiguity and do solely what was obviously intended (-t 1=1 would be the {tab} one that takes values for a hash not -t for --text).
Unlike the OP, whose GL warning is conditioned on receiving an ambiguous implicit/default abbrev option at runtime, I'd expect describe_options to throw a warning at least, if not croak ourright, on finding such explicit ambiguity between @opt_spec elements' requested abbrevs.
(But yeah, if it hurts when i do that, don't do that. :-) )
Anyway, we do like the module. It's like VMS arg handling without the rest of VMS, win.

@rjbs
Copy link
Owner

rjbs commented Jan 29, 2016

I agree that something should be done. given test|t and toast|t, I would hope for an error as early as possible. I may fix that myself in the future.

I am unlikely to fix how anything behaves when the getopt options are changed, though. In reality, I've been daydreaming about writing a replacement that totally bypasses Getopt, just to avoid any configuration being possible. :-)

@n1vux
Copy link

n1vux commented Jan 29, 2016

On Thu, Jan 28, 2016 at 7:45 PM, Ricardo Signes [email protected]
wrote:

​Thanks for feedback.​

I am unlikely to fix how anything behaves when the getopt options are

changed, though. In reality, I've been daydreaming about writing a
replacement that totally bypasses Getopt, just to avoid any configuration
being possible. :-)

[ ​To be clear, when i say "changed" i meant a later pull-request adding
features to the script-file (without reading carefully what prior
features used for options), accumulating options from multiple
source-files by injection, inheritance, or what-ever. ]

​ Bill​

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants