Skip to content

Commit

Permalink
Unrolled build for rust-lang#116732
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#116732 - onur-ozkan:resolve-linked-x, r=Mark-Simulacrum

Make x capable of resolving symlinks

When bootstrapping from outside of the rust source, instead of calling 'x' from the absolute path
(like /home/user/rust/x), we should be able to link 'x' from the rust source to binary paths so it can be used easily. Before this change, 'x' was not capable of finding 'x.py' when called from the linked file.
  • Loading branch information
rust-timer committed Oct 15, 2023
2 parents f70779b + e0fe1d6 commit a0342cd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions x
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ set -eu
sh -n "$0"

realpath() {
if [ -d "$1" ]; then
CDPATH='' command cd "$1" && pwd -P
local path="$1"
if [ -L "$path" ]; then
readlink -f "$path"
elif [ -d "$path" ]; then
(cd -P "$path" && pwd)
else
echo "$(realpath "$(dirname "$1")")/$(basename "$1")"
echo "$(realpath "$(dirname "$path")")/$(basename "$path")"
fi
}

Expand Down

0 comments on commit a0342cd

Please sign in to comment.