fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a1baf97f5
master
1# localization: skip(uses-apropos) 2 3if not command -qs man 4# see #5329 and discussion at https://github.com/fish-shell/fish-shell/commit/13e025bdb01cc4dd08463ec497a0a3495873702f 5exit 6end 7 8function man 9set -l manpath 10if __fish_tried_to_embed_manpages 11# If we have an embedded page, reuse a function that happens to do 12# the right thing. 13if not set -q argv[ 2 ] && 14status list-files"man/man1/$ ( __fish_canonicalize_builtin $argv ) .1" &> /dev/null 15__fish_print_help $argv [ 1 ] 16return 17end 18else if set -l fish_manpath( path filter -d$__fish_man_dir ) 19# Prepend fish's man directory if available. 20 21# Work around the "builtin" manpage that everything symlinks to, 22# by prepending our fish datadir to man. This also ensures that man gives fish's 23# man pages priority, without having to put fish's bin directories first in $PATH. 24 25# Preserve the existing MANPATH, and default to the system path (the empty string). 26set manpath$fish_manpath ( 27if set -q MANPATH 28string join --\n $MANPATH 29else if set -l p( command man -p2> /dev/null) 30# NetBSD's man uses "-p" to print the path. 31# FreeBSD's man also has a "-p" option, but that requires an argument. 32# Other mans (men?) don't seem to have it. 33# 34# Unfortunately NetBSD prints things like "/usr/share/man/man1", 35# while not allowing them as $MANPATH components. 36# What it needs is just "/usr/share/man". 37# 38# So we strip the last component. 39# This leaves a few wrong directories, but that should be harmless. 40string replace -r'[^/]+$' '' $p 41else 42echo '' 43end 44) 45 46if test ( count $argv ) -eq 1 47set argv( __fish_canonicalize_builtin $argv ) 48end 49end 50set -q manpath[ 1 ] 51and set -lx MANPATH$manpath 52 53command man$argv 54end