fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerDo not embed man pages in CMake buildsa1baf97f5

master
2.0 KiB54 linesraw
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
5    exit
6end
7
8function man
9    set -l manpath
10    if __fish_tried_to_embed_manpages
11        # If we have an embedded page, reuse a function that happens to do
12        # the right thing.
13        if not set -q argv[2] &&
14                status list-files "man/man1/$(__fish_canonicalize_builtin $argv).1" &>/dev/null
15            __fish_print_help $argv[1]
16            return
17        end
18    else 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).
26        set manpath $fish_manpath (
27            if set -q MANPATH
28                string join -- \n $MANPATH
29            else if set -l p (command man -p 2>/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.
40                string replace -r '[^/]+$' '' $p
41            else
42                echo ''
43            end
44        )
45
46        if test (count $argv) -eq 1
47            set argv (__fish_canonicalize_builtin $argv)
48        end
49    end
50    set -q manpath[1]
51    and set -lx MANPATH $manpath
52
53    command man $argv
54end