mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-24 03:21:15 -03:00
functions/man: fix for embedded fish-* man pages
"man abbr" works in embed-data builds, but "man fish-faq" doesn't. This is because it delegates to __fish_print_help fish-faq which skips all lines until the NAME section: contains -- $name NAME; and set have_name 1 but the NAME section doesn't exist for this man pages, it only exists for docs from doc_src/cmds/*.rst. Let's use the "man" utility instead; this is also what the user asked for. Unfortunately we can't use "status get-file | man -l -" because that's not supported on BSD man. Note that man displays the basename of the file, so make sure it looks good.
This commit is contained in:
@@ -55,10 +55,19 @@ function man --description "Format and display the on-line manual pages"
|
||||
end
|
||||
end
|
||||
|
||||
set -l tmpdir
|
||||
if not set -q argv[2] && status list-files "man/man1/$argv[1].1" &>/dev/null
|
||||
__fish_print_help $argv
|
||||
return
|
||||
set tmpdir (__fish_mktemp_relative -d fish-man)
|
||||
status get-file "man/man1/$argv[1].1" >$tmpdir/$argv.1
|
||||
set argv $tmpdir/$argv.1
|
||||
end
|
||||
|
||||
command man $argv
|
||||
set -l saved_status $status
|
||||
|
||||
if set -q tmpdir[1]
|
||||
rm -r $tmpdir
|
||||
end
|
||||
|
||||
return $saved_status
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user