mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 15:01:16 -03:00
__fish_print_help: use man as-is
Since 0fea1dae8c (__fish_print_help: Make formatting more man-like,
2024-10-03), there is barely any difference left between "man abbr"
and "abbr -h".
The main difference is that it looks almost like man but is actually
nroff/mandoc and less. This means it doesn't support environment
variables like MANWIDTH and possibly others.
Let's use full "man" for now.
This matches what "git foo --help" does so it's widely accepted.
Keep around a fallback for a while, in case users/packagers fail to
install the new "man" dependency.
In future, "abbr -h" (as opposed to "abbr --help") could show a more
concise version, not sure.
Closes #11786
This commit is contained in:
@@ -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.
|
- 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.
|
- 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`)
|
- ``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
|
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).
|
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 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`).
|
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.
|
- 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/.
|
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`).
|
If that doesn't match your setup, set the Rust_COMPILER and Rust_CARGO cmake variables (:issue:`11328`).
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ Running fish requires:
|
|||||||
The following optional features also have specific requirements:
|
The following optional features also have specific requirements:
|
||||||
|
|
||||||
- builtin commands that have the ``--help`` option or print usage
|
- builtin commands that have the ``--help`` option or print usage
|
||||||
messages require ``nroff`` or ``mandoc`` for
|
messages require ``man`` for display
|
||||||
display
|
|
||||||
- automated completion generation from manual pages requires Python 3.5+
|
- automated completion generation from manual pages requires Python 3.5+
|
||||||
- the ``fish_config`` web configuration tool requires Python 3.5+ and a web browser
|
- 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
|
- system clipboard integration (with the default Ctrl-V and Ctrl-X
|
||||||
|
|||||||
4
debian/control
vendored
4
debian/control
vendored
@@ -25,8 +25,8 @@ Depends: bsdextrautils | bsdmainutils,
|
|||||||
file,
|
file,
|
||||||
# for the msgfmt command
|
# for the msgfmt command
|
||||||
gettext-base,
|
gettext-base,
|
||||||
# for nroff and preconv
|
# for man
|
||||||
groff-base,
|
man-db,
|
||||||
# for terminal definitions
|
# for terminal definitions
|
||||||
ncurses-base,
|
ncurses-base,
|
||||||
# for kill
|
# for kill
|
||||||
|
|||||||
3
po/de.po
3
po/de.po
@@ -43537,6 +43537,9 @@ msgstr ""
|
|||||||
msgid "Print help for the given subcommand(s)"
|
msgid "Print help for the given subcommand(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Print help for the specified fish function or builtin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print help info and exit"
|
msgid "Print help info and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
3
po/en.po
3
po/en.po
@@ -43533,6 +43533,9 @@ msgstr ""
|
|||||||
msgid "Print help for the given subcommand(s)"
|
msgid "Print help for the given subcommand(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Print help for the specified fish function or builtin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print help info and exit"
|
msgid "Print help info and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
3
po/fr.po
3
po/fr.po
@@ -43634,6 +43634,9 @@ msgstr ""
|
|||||||
msgid "Print help for the given subcommand(s)"
|
msgid "Print help for the given subcommand(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Print help for the specified fish function or builtin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print help info and exit"
|
msgid "Print help info and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
3
po/pl.po
3
po/pl.po
@@ -43529,6 +43529,9 @@ msgstr ""
|
|||||||
msgid "Print help for the given subcommand(s)"
|
msgid "Print help for the given subcommand(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Print help for the specified fish function or builtin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print help info and exit"
|
msgid "Print help info and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -43550,6 +43550,9 @@ msgstr ""
|
|||||||
msgid "Print help for the given subcommand(s)"
|
msgid "Print help for the given subcommand(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Print help for the specified fish function or builtin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print help info and exit"
|
msgid "Print help info and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
3
po/sv.po
3
po/sv.po
@@ -43532,6 +43532,9 @@ msgstr ""
|
|||||||
msgid "Print help for the given subcommand(s)"
|
msgid "Print help for the given subcommand(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Print help for the specified fish function or builtin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print help info and exit"
|
msgid "Print help info and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -43532,6 +43532,9 @@ msgstr ""
|
|||||||
msgid "Print help for the given subcommand(s)"
|
msgid "Print help for the given subcommand(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Print help for the specified fish function or builtin"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print help info and exit"
|
msgid "Print help info and exit"
|
||||||
msgstr "打印帮助信息和退出"
|
msgstr "打印帮助信息和退出"
|
||||||
|
|
||||||
|
|||||||
@@ -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]
|
set -l item $argv[1]
|
||||||
switch $item
|
switch $item
|
||||||
case !
|
case !
|
||||||
@@ -11,8 +11,41 @@ function __fish_print_help --description "Print help message for the specified f
|
|||||||
set item test
|
set item test
|
||||||
end
|
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
|
# 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
|
return 2
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -76,6 +109,7 @@ function __fish_print_help --description "Print help message for the specified f
|
|||||||
set -l state blank
|
set -l state blank
|
||||||
set -l have_name
|
set -l have_name
|
||||||
begin
|
begin
|
||||||
|
string join \n $error_message
|
||||||
for line in $help
|
for line in $help
|
||||||
# categorize the line
|
# categorize the line
|
||||||
set -l line_type
|
set -l line_type
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ function __fish_whatis_current_token -d "Show man page entries or function descr
|
|||||||
and set desc "$token - $funcinfo[5]"
|
and set desc "$token - $funcinfo[5]"
|
||||||
|
|
||||||
case builtin
|
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
|
case file
|
||||||
set -l tmpdesc (whatis $token 2>/dev/null)
|
set -l tmpdesc (whatis $token 2>/dev/null)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# RUN: %fish %s
|
# RUN: %fish %s
|
||||||
# Test redirecting builtin help with a pipe
|
# 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)
|
set -lx __fish_data_dir (mktemp -d)
|
||||||
mkdir -p $__fish_data_dir/man/man1
|
mkdir -p $__fish_data_dir/man/man1
|
||||||
|
|||||||
Reference in New Issue
Block a user