diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7b8b81908..9c6e7b27d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -58,6 +58,7 @@ Interactive improvements - Pasted commands are now stripped of any :code:`$\ ` command prefixes, which are sometimes used in copy-pasted code snippets. - The :kbd:`alt-s` binding will now also use ``run0`` if available. - ``funced`` will now edit copied functions directly, instead of the file where ``function --copy`` was invoked. (:issue:`11614`) +- built-in help options as ``abbr --help`` now use ``man`` directly, meaning that variables like :envvar:`MANWIDTH` are respected (:issue:`11786`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,6 +96,8 @@ For distributors it will act like the given tool (i.e. it's a multi-call binary). This allows truly distributing fish as a single file. This means they can be replaced with symlinks if you want to save disk space (:issue:`10876`). +- builtin commands that support the ``--help`` option now require the ``man`` program. + The direct dependency on either of ``mandoc`` or ``nroff`` has been removed. - The CMake build configuration has been simplified and no longer second-guesses rustup. It will run rustc and cargo via :envvar:`PATH` or in ~/.cargo/bin/. If that doesn't match your setup, set the Rust_COMPILER and Rust_CARGO cmake variables (:issue:`11328`). diff --git a/README.rst b/README.rst index 3a3a0fe8b..04126a917 100644 --- a/README.rst +++ b/README.rst @@ -97,8 +97,7 @@ Running fish requires: The following optional features also have specific requirements: - builtin commands that have the ``--help`` option or print usage - messages require ``nroff`` or ``mandoc`` for - display + messages require ``man`` for display - automated completion generation from manual pages requires Python 3.5+ - the ``fish_config`` web configuration tool requires Python 3.5+ and a web browser - system clipboard integration (with the default Ctrl-V and Ctrl-X diff --git a/debian/control b/debian/control index 60235292d..1e0d0634d 100644 --- a/debian/control +++ b/debian/control @@ -25,8 +25,8 @@ Depends: bsdextrautils | bsdmainutils, file, # for the msgfmt command gettext-base, -# for nroff and preconv - groff-base, +# for man + man-db, # for terminal definitions ncurses-base, # for kill diff --git a/po/de.po b/po/de.po index 8d3091375..99387901e 100644 --- a/po/de.po +++ b/po/de.po @@ -43537,6 +43537,9 @@ msgstr "" msgid "Print help for the given subcommand(s)" msgstr "" +msgid "Print help for the specified fish function or builtin" +msgstr "" + msgid "Print help info and exit" msgstr "" diff --git a/po/en.po b/po/en.po index 7c01b8432..5e252232e 100644 --- a/po/en.po +++ b/po/en.po @@ -43533,6 +43533,9 @@ msgstr "" msgid "Print help for the given subcommand(s)" msgstr "" +msgid "Print help for the specified fish function or builtin" +msgstr "" + msgid "Print help info and exit" msgstr "" diff --git a/po/fr.po b/po/fr.po index 19280ddfe..fee9965fb 100644 --- a/po/fr.po +++ b/po/fr.po @@ -43634,6 +43634,9 @@ msgstr "" msgid "Print help for the given subcommand(s)" msgstr "" +msgid "Print help for the specified fish function or builtin" +msgstr "" + msgid "Print help info and exit" msgstr "" diff --git a/po/pl.po b/po/pl.po index 4962ef431..0736d43c3 100644 --- a/po/pl.po +++ b/po/pl.po @@ -43529,6 +43529,9 @@ msgstr "" msgid "Print help for the given subcommand(s)" msgstr "" +msgid "Print help for the specified fish function or builtin" +msgstr "" + msgid "Print help info and exit" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index 999305824..fb997d082 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -43550,6 +43550,9 @@ msgstr "" msgid "Print help for the given subcommand(s)" msgstr "" +msgid "Print help for the specified fish function or builtin" +msgstr "" + msgid "Print help info and exit" msgstr "" diff --git a/po/sv.po b/po/sv.po index 1b6100f12..54d1d1ed8 100644 --- a/po/sv.po +++ b/po/sv.po @@ -43532,6 +43532,9 @@ msgstr "" msgid "Print help for the given subcommand(s)" msgstr "" +msgid "Print help for the specified fish function or builtin" +msgstr "" + msgid "Print help info and exit" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index 4a3a2e643..07c64a504 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -43532,6 +43532,9 @@ msgstr "" msgid "Print help for the given subcommand(s)" msgstr "" +msgid "Print help for the specified fish function or builtin" +msgstr "" + msgid "Print help info and exit" msgstr "打印帮助信息和退出" diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index dc15b816e..f18aad7f8 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -1,4 +1,4 @@ -function __fish_print_help --description "Print help message for the specified fish function or builtin" +function __fish_print_help --description "Print help for the specified fish function or builtin" set -l item $argv[1] switch $item case ! @@ -11,8 +11,41 @@ function __fish_print_help --description "Print help message for the specified f set item test end + if not command -v man >/dev/null + __fish_print_help_pre_4.1 \ + $item \ + "fish: warning: Unknown command 'man', falling back to 'mandoc' or 'nroff'" + return + end + + # NOTE: this is duplicated with share/functions/man.fish, but that + # function is not always defined. + set -l tmpdir + set -l file (path filter -- \ + $__fish_data_dir/man/man1/$item.1 \ + $__fish_data_dir/man/man1/$item.1.gz) + or begin + set -l contents "$(status get-file man/man1/$item.1)" + or return 2 + set tmpdir (__fish_mktemp_relative -d fish-print-help) + or return + set file $tmpdir/$item.1 + printf %s\n $contents >$file + end + command man $file[1] + set -l saved_status $status + if set -q tmpdir[1] + command rm -r $tmpdir + end + return $saved_status +end + +function __fish_print_help_pre_4.1 --description "Print help message for the specified fish function or builtin" + set -l item $argv[1] + set -l error_message $argv[2] # Do nothing if the file does not exist - if not path is -- $__fish_data_dir/man/man1/$item.1 $__fish_data_dir/man/man1/$item.1.gz; and not status get-file man/man1/$item.1 >/dev/null + if not path is -- $__fish_data_dir/man/man1/$item.1 $__fish_data_dir/man/man1/$item.1.gz + and not status get-file man/man1/$item.1 >/dev/null return 2 end @@ -76,6 +109,7 @@ function __fish_print_help --description "Print help message for the specified f set -l state blank set -l have_name begin + string join \n $error_message for line in $help # categorize the line set -l line_type diff --git a/share/functions/__fish_whatis_current_token.fish b/share/functions/__fish_whatis_current_token.fish index a731cf90e..f4ac6f4c8 100644 --- a/share/functions/__fish_whatis_current_token.fish +++ b/share/functions/__fish_whatis_current_token.fish @@ -18,7 +18,8 @@ function __fish_whatis_current_token -d "Show man page entries or function descr and set desc "$token - $funcinfo[5]" case builtin - set desc (__fish_print_help $token | awk "/./ { getline; print; exit }" | string trim) + # Since man pages can be localized, we can't look for "NAME". + set desc (__fish_print_help $token | sed -n 4p | string trim) case file set -l tmpdesc (whatis $token 2>/dev/null) diff --git a/tests/checks/print-help.fish b/tests/checks/print-help.fish index b5bf1172d..ca8d54223 100644 --- a/tests/checks/print-help.fish +++ b/tests/checks/print-help.fish @@ -1,6 +1,6 @@ # RUN: %fish %s # Test redirecting builtin help with a pipe -# REQUIRES: command -v mandoc || command -v nroff +# REQUIRES: command -v man set -lx __fish_data_dir (mktemp -d) mkdir -p $__fish_data_dir/man/man1