From 6b536922af23086197fd9fa5a9e14dbcc84e57c8 Mon Sep 17 00:00:00 2001 From: Sam H Date: Mon, 26 Dec 2016 14:46:53 -0500 Subject: [PATCH] Append paths from /etc/manpaths and /etc/manpaths.d/* to MANPATH, for #1092. * Only append paths if `MANPATH` is already set, to match behavior of macOS `path_helper` utility. * Use the same technique as is used above to set PATH from /etc/paths and /etc/paths.d/*. --- share/config.fish | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/share/config.fish b/share/config.fish index debbe77c4..a5db25a3b 100644 --- a/share/config.fish +++ b/share/config.fish @@ -144,6 +144,29 @@ set -xg PATH $__fish_tmp_path set -e __fish_tmp_path functions -e __fish_load_path_helper_paths +# OS X-ism: Load the manpath files out of /etc/manpaths and /etc/manpaths.d/* +if set -q MANPATH + set -g __fish_tmp_manpath $MANPATH + function __fish_load_manpath_helper_manpaths + # We want to rearrange the manpath to reflect this order. Delete that manpath component if it exists and then prepend it. + # Since we are prepending but want to preserve the order of the input file, we reverse the array, append, and then reverse it again + set __fish_tmp_manpath $__fish_tmp_manpath[-1..1] + while read -l new_manpath_comp + if test -d $new_manpath_comp + set -l where (contains -i -- $new_manpath_comp $__fish_tmp_manpath) + and set -e __fish_tmp_manpath[$where] + set __fish_tmp_manpath $new_manpath_comp $__fish_tmp_manpath + end + end + set __fish_tmp_manpath $__fish_tmp_manpath[-1..1] + end + test -r /etc/manpaths ; and __fish_load_manpath_helper_manpaths < /etc/manpaths + for manpathfile in /etc/manpaths.d/* ; __fish_load_manpath_helper_manpaths < $manpathfile ; end + set -xg MANPATH $__fish_tmp_manpath + set -e __fish_tmp_manpath + functions -e __fish_load_manpath_helper_manpaths +end + # Add a handler for when fish_user_path changes, so we can apply the same changes to PATH # Invoke it immediately to apply the current value of fish_user_path