diff options
| author | onur-ozkan <work@onurozkan.dev> | 2023-10-14 17:53:33 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2023-10-14 17:53:33 +0300 |
| commit | e0fe1d6008f0ba8b395636dd1c850fa91cd2f9a2 (patch) | |
| tree | f06adefc278e448c30a5a3ec327fb2551441c20e | |
| parent | 39acbed8d6d3d87ca05f204ed0309fc44e5ffa37 (diff) | |
| download | rust-e0fe1d6008f0ba8b395636dd1c850fa91cd2f9a2.tar.gz rust-e0fe1d6008f0ba8b395636dd1c850fa91cd2f9a2.zip | |
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 <work@onurozkan.dev>
| -rwxr-xr-x | x | 9 |
1 files 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 } |
