fish_print_hg_root: Don't break if $PWD includes newlines

Fixes #11348
This commit is contained in:
Fabian Boehm
2025-04-02 16:59:21 +02:00
parent 9c5be2a2d8
commit 5e25cdaa6f

View File

@@ -7,16 +7,16 @@ function fish_print_hg_root
# Find an hg directory above $PWD
# without calling `hg root` because that's too slow
set -l root
set -l dir (pwd -P 2>/dev/null)
set -l dir "$(pwd -P 2>/dev/null)"
or return 1
while test $dir != /
while not contains -- "$dir" "" / .
if test -f $dir'/.hg/dirstate'
echo $dir/.hg
return 0
end
# Go up one directory
set dir (string replace -r '[^/]*/?$' '' $dir)
set dir (path dirname -- $dir)
end
return 1