NotTheDr01ds · GitHub

  • fish 3.1.0
  • Linux kings 4.4.0-18362-Microsoft Env vars not working. #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
  • screen-256color
  • Reproduced in "no customizations" shell
function foo
  argparse 'h/help' -- $argv
  or begin
    set -l s $status
    echo Usage:  foo -h
    return $s
  end
  echo Main function blah blah
end

The next two lines are optional:

funcsave foo
source ~/.config/fish/functions/foo.fish

Then: foo --bar

Expected:

foo: Unknown option '--bar'
Usage: foo -h

But instead we get script debugging info:

foo: Unknown option '--bar'
~/.config/fish/functions/foo.fish (line 2):
  argparse 'h/help' -- $argv
  ^
in function 'foo' with arguments '--bar'
Usage: foo -h

... which is ugly and really not useful to the end-user of the script. They just need to know that they entered an incorrect option and to try again. As it says in builtin_argparse.cpp, "... this particular error is not an error in argparse usage." So why is it still treated as such by printing script debug info?

This is also evident in any function shipped with fish that uses argparse. For instance:

funced --edior

Read the original on github.com ↗