fork/fish-shell

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

Fabian Boehmfish_print_hg_root: Don't break if $PWD includes newlines5e25cdaa6

master
534 B23 linesraw
1function fish_print_hg_root
2    # If hg isn't installed, there's nothing we can do
3    if not command -sq hg
4        return 1
5    end
6
7    # Find an hg directory above $PWD
8    # without calling `hg root` because that's too slow
9    set -l root
10    set -l dir "$(pwd -P 2>/dev/null)"
11    or return 1
12
13    while not contains -- "$dir" "" / .
14        if test -f $dir'/.hg/dirstate'
15            echo $dir/.hg
16            return 0
17        end
18        # Go up one directory
19        set dir (path dirname -- $dir)
20    end
21
22    return 1
23end