diff --git a/po/fr.po b/po/fr.po index 3503d1a04..3d8af033c 100644 --- a/po/fr.po +++ b/po/fr.po @@ -3556,7 +3556,7 @@ msgstr "" #: /tmp/fish/explicit/share/functions/cdh.fish:5 msgid "Select directory by letter or number: " -msgstr "Sélectionner un dossier par lettre ou chiffre" +msgstr "Sélectionner un dossier par lettre ou chiffre : " #: /tmp/fish/explicit/share/functions/cdh.fish:6 msgid "" diff --git a/share/completions/git.fish b/share/completions/git.fish index 970c7e1f5..f96a8698e 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -1923,8 +1923,8 @@ for file in $PATH/git-* and continue complete -C "git-$subcommand " >/dev/null - if [ (complete git-$subcommand | count) -gt 0 ] - complete git -f -n "__fish_git_using_command $subcommand" -a "(__fish_git_complete_custom_command $subcommand)" + if [ (complete -c git-$subcommand | count) -gt 0 ] + complete -c git -f -n "__fish_git_using_command $subcommand" -a "(__fish_git_complete_custom_command $subcommand)" end set -a __fish_git_custom_commands_completion $subcommand end diff --git a/share/completions/mkpasswd.fish b/share/completions/mkpasswd.fish new file mode 100644 index 000000000..a86f97ac1 --- /dev/null +++ b/share/completions/mkpasswd.fish @@ -0,0 +1,12 @@ +function __fish_mkpasswd_methods --description "Complete hashing methods for mkpasswd" + mkpasswd -m help | tail -n +2 | string replace -r '^(\S+)\s+(\S.*)' '$1\t$2' + echo -e "help\tList available methods" +end + +complete -c mkpasswd -f +complete -c mkpasswd -s S -l salt -x -d 'Use given string as salt' +complete -c mkpasswd -s R -l rounds -x -d 'Use given number of rounds' +complete -c mkpasswd -s m -l method -xa "(__fish_mkpasswd_methods)" -d 'Compute the password using the given method' +complete -c mkpasswd -s 5 -d 'Like --method=md5crypt' +complete -c mkpasswd -s P -l password-fd -x -d 'Read the password from the given file descriptor' +complete -c mkpasswd -s s -l stdin -d 'Read the password from stdin' diff --git a/share/completions/source.fish b/share/completions/source.fish index f80bd6b8f..0f05b04fd 100644 --- a/share/completions/source.fish +++ b/share/completions/source.fish @@ -1,2 +1,2 @@ -complete source -k -xa '(__fish_complete_suffix .fish)' -complete source -s h -l help -d 'Display help and exit' +complete -c source -k -xa '(__fish_complete_suffix .fish)' +complete -c source -s h -l help -d 'Display help and exit' diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index 788e4314c..066dcd352 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -10,7 +10,7 @@ function __fish_print_help --description "Print help message for the specified f # Do nothing if the file does not exist if not test -e "$__fish_data_dir/man/man1/$item.1" -o -e "$__fish_data_dir/man/man1/$item.1.gz" - return + return 2 end # Render help output, save output into the variable 'help' diff --git a/share/functions/funced.fish b/share/functions/funced.fish index 394a0daf6..5d7df3271 100644 --- a/share/functions/funced.fish +++ b/share/functions/funced.fish @@ -130,7 +130,7 @@ function funced --description 'Edit function definition' end set -l stat $status - rm $tmpname >/dev/null + command rm $tmpname >/dev/null and rmdir $tmpdir >/dev/null return $stat end diff --git a/src/builtin.cpp b/src/builtin.cpp index bd31ebe2d..da8bdeb18 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -155,7 +155,6 @@ int parse_help_only_cmd_opts(struct help_only_cmd_opts_t &opts, int *optind, int /// Process and print help for the specified builtin or function. void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wchar_t *name, wcstring *error_message) { - UNUSED(streams); // This won't ever work if no_exec is set. if (no_exec()) return; const wcstring name_esc = escape_string(name, ESCAPE_ALL); @@ -166,8 +165,10 @@ void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wch // If it's an error, redirect the output of __fish_print_help to stderr ios.push_back(std::make_shared(STDOUT_FILENO, STDERR_FILENO)); } - parser.eval(cmd, ios); - // ignore the exit status of __fish_print_help + auto res = parser.eval(cmd, ios); + if (res.status.exit_code() == 2) { + streams.err.append_format(BUILTIN_ERR_MISSING_HELP, name_esc.c_str()); + } } /// Perform error reporting for encounter with unknown option. diff --git a/src/builtin.h b/src/builtin.h index 88e01769a..0d7831c25 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -36,6 +36,10 @@ enum { COMMAND_NOT_BUILTIN, BUILTIN_REGULAR, BUILTIN_FUNCTION }; /// Error message on missing argument. #define BUILTIN_ERR_MISSING _(L"%ls: Expected argument for option %ls\n") +/// Error message on missing man page. +#define BUILTIN_ERR_MISSING_HELP \ + _(L"fish: Missing man page for '%ls'. Did you install the documentation?\n") + /// Error message on invalid combination of options. #define BUILTIN_ERR_COMBO _(L"%ls: Invalid combination of options\n") diff --git a/tests/checks/andandoror.fish b/tests/checks/andandoror.fish index 2d937ade3..60f7a9a0a 100644 --- a/tests/checks/andandoror.fish +++ b/tests/checks/andandoror.fish @@ -113,22 +113,28 @@ echo comment after conjunction # --help works builtin and --help >/dev/null +# CHECKERR: fish: Missing man page {{.*}} echo $status and --help >/dev/null +# CHECKERR: fish: Missing man page {{.*}} echo $status # CHECK: 0 # CHECK: 0 builtin or --help >/dev/null +# CHECKERR: fish: Missing man page {{.*}} echo $status or --help >/dev/null +# CHECKERR: fish: Missing man page {{.*}} echo $status # CHECK: 0 # CHECK: 0 builtin not --help >/dev/null +# CHECKERR: fish: Missing man page {{.*}} echo $status not --help >/dev/null +# CHECKERR: fish: Missing man page {{.*}} echo $status # CHECK: 0 # CHECK: 0 diff --git a/tests/checks/scoping.fish b/tests/checks/scoping.fish index c07848c8c..8153da115 100644 --- a/tests/checks/scoping.fish +++ b/tests/checks/scoping.fish @@ -241,6 +241,7 @@ echo 7 $status # no passthrough #CHECK: 7 4 false set -h >/dev/null +# CHECKERR: fish: Missing man page {{.*}} echo 8 $status # no passthrough #CHECK: 8 0 true