From 04f6b8f99242eb61756fe294dd9d46536c1c8571 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 19 Sep 2025 16:48:05 +0200 Subject: [PATCH] fix ./x readdir logic when CDPATH is set --- x | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x b/x index 551cfe6efbf33..4fce0be219e7c 100755 --- a/x +++ b/x @@ -15,7 +15,8 @@ realpath() { if [ -L "$path" ]; then readlink -f "$path" elif [ -d "$path" ]; then - (cd -P "$path" && pwd) + # "cd" is not always silent (e.g. when CDPATH is set), so discard its output. + (cd -P "$path" >/dev/null && pwd) else echo "$(realpath "$(dirname "$path")")/$(basename "$path")" fi