From 5e25cdaa6f09b634d2a8ea8ac508c7d7f7f91020 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 2 Apr 2025 16:59:21 +0200 Subject: [PATCH] fish_print_hg_root: Don't break if $PWD includes newlines Fixes #11348 --- share/functions/fish_print_hg_root.fish | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/functions/fish_print_hg_root.fish b/share/functions/fish_print_hg_root.fish index 65625f9ea..50df1e3c6 100644 --- a/share/functions/fish_print_hg_root.fish +++ b/share/functions/fish_print_hg_root.fish @@ -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