fork/fish-shell

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

Johannes Altmanninger__fish_macos_set_env: match macOS "path_helper" if MANPATH is overridden6c267e88a

master
945 B29 linesraw
1# localization: tier1
2# Adapt construct_path from the macOS /usr/libexec/path_helper
3# executable for fish; see
4# https://opensource.apple.com/source/shell_cmds/shell_cmds-203/path_helper/path_helper.c.auto.html .
5function __fish_macos_set_env -d "set an environment variable like path_helper does (macOS only)"
6    set -l result
7
8    # Populate path according to config files
9    for path_file in $argv[2] $argv[3]/*
10        for entry in (string split : <? $path_file)
11            if not contains -- $entry $result
12                test -n "$entry"
13                and set -a result $entry
14            end
15        end
16    end
17
18    # Merge in any existing path elements
19    for existing_entry in $$argv[1]
20        if test -n $existing_entry; and not contains -- $existing_entry $result
21            set -a result $existing_entry
22        end
23    end
24    if test $argv[1] = MANPATH
25        set -a result ""
26    end
27
28    set -xg $argv[1] $result
29end