From c3c3a9518cec335572d57f89c8e9848f0a81efce Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 29 Aug 2025 11:40:42 +0200 Subject: [PATCH] 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. --- share/functions/man.fish | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/share/functions/man.fish b/share/functions/man.fish index 671504c24..918e1f242 100644 --- a/share/functions/man.fish +++ b/share/functions/man.fish @@ -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