Stop printing help summary on error

This now displays

- the error message

- a (significantly shorter) backtrace

- A call to open `help $cmd` if necessary

See #5434.
Fixes #3404.
This commit is contained in:
Fabian Homborg
2019-03-26 19:13:01 +01:00
parent 88a935d8d1
commit 88d2d54276
15 changed files with 71 additions and 132 deletions

View File

@@ -548,7 +548,13 @@ static int argparse_parse_flags(parser_t &parser, const argparse_cmd_opts_t &opt
retval = validate_and_store_implicit_int(parser, opts, arg_contents, w, long_idx,
streams);
} else {
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
streams.err.append_format(BUILTIN_ERR_UNKNOWN, cmd, argv[w.woptind - 1]);
// We don't use builtin_print_error_trailer as that
// says to use the cmd help,
// which doesn't work if it's a command that does not belong to fish.
//
// Plus this particular error is not an error in argparse usage.
streams.err.append(parser.current_line());
retval = STATUS_INVALID_ARGS;
}
if (retval != STATUS_CMD_OK) return retval;