Skip to content

Commit ba50a91

Browse files
matthiaskrgrMuscraft
authored andcommitted
Rollup merge of rust-lang#146777 - RalfJung:x-cdpath, r=Kobzol
fix ./x readdir logic when CDPATH is set Fixes rust-lang#146769 r? ``@Kobzol``
2 parents f6ecb9e + 3c26829 commit ba50a91

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

x

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ realpath() {
1515
if [ -L "$path" ]; then
1616
readlink -f "$path"
1717
elif [ -d "$path" ]; then
18-
(cd -P "$path" && pwd)
18+
# "cd" is not always silent (e.g. when CDPATH is set), so discard its output.
19+
(cd -P "$path" >/dev/null && pwd)
1920
else
2021
echo "$(realpath "$(dirname "$path")")/$(basename "$path")"
2122
fi

0 commit comments

Comments
 (0)