From dfd1e3a36218921e4ff5ce93da1c80d9ca417dc2 Mon Sep 17 00:00:00 2001 From: lapingenieur Date: Sun, 14 Mar 2021 20:13:30 +0100 Subject: [PATCH 1/6] Added a ':' at the end of a french translation --- po/fr.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 "" From 38cd373ca34641e3de28a27dca4c97a582ee7200 Mon Sep 17 00:00:00 2001 From: exploide Date: Sun, 14 Mar 2021 20:00:09 +0100 Subject: [PATCH 2/6] added completions for mkpasswd --- share/completions/mkpasswd.fish | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 share/completions/mkpasswd.fish 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' From f95f12f5e7fc5da915ca9cc35879d5718bffe6be Mon Sep 17 00:00:00 2001 From: lapingenieur Date: Mon, 15 Mar 2021 20:38:35 +0100 Subject: [PATCH 3/6] changed 'rm' to 'command rm' if rm is aliased to 'rm -i' then rm will ask to delete the cache file after funced edited the file which is anoying --- share/functions/funced.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 582675c96ae453ba5966f9fa1669fc90fc8fcd5c Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 15 Mar 2021 22:27:04 +0100 Subject: [PATCH 4/6] completions/git: restore forward-compatibility by using "complete -c" After a fish installation is upgraded to 3.2.0, active shells could throw an error attempting to load Git completions. It's just a transient error but also easily avoidable by using the old style. See #7822 --- share/completions/git.fish | 4 ++-- share/completions/source.fish | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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/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' From f9e131aa93f0d02877a25049834a06985a1622d5 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 15 Mar 2021 22:59:37 +0100 Subject: [PATCH 5/6] Show an error when "builtin -h" fails to find a man page Prior to this commit "builtin -h" would silently fail when no documentation is installed. This happens when running fish without installing it, or when the docs are not installed. See #7824 --- share/functions/__fish_print_help.fish | 2 +- src/builtin.cpp | 7 ++++--- src/builtin.h | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) 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/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") From efcfec0ba1e1c594ab61621379516ab6c177c6c1 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 15 Mar 2021 23:12:35 +0100 Subject: [PATCH 6/6] fixup! Show an error when "builtin -h" fails to find a man page --- tests/checks/andandoror.fish | 6 ++++++ tests/checks/scoping.fish | 1 + 2 files changed, 7 insertions(+) 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