From e0fe1d6008f0ba8b395636dd1c850fa91cd2f9a2 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sat, 14 Oct 2023 17:53:33 +0300 Subject: [PATCH] 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. Signed-off-by: onur-ozkan --- x | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x b/x index ef3eb8b04b4..426b58d0d4e 100755 --- a/x +++ b/x @@ -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 }