|
30 | 30 | open my $fh, ">", $install_to
|
31 | 31 | or die "Could not open $install_to: $!";
|
32 | 32 | if ($relocatable) {
|
33 |
| - printf $fh <<'EOS'; |
34 |
| -#!/bin/bash |
35 |
| -
|
36 |
| -# Sourced from https://stackoverflow.com/a/246128/1975049 |
37 |
| -SOURCE="${BASH_SOURCE[0]}" |
38 |
| -while [ -h "$SOURCE" ]; do |
39 |
| - DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" |
40 |
| - SOURCE="$(readlink "$SOURCE")" |
41 |
| - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" |
42 |
| -done |
43 |
| -DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" |
| 33 | + print $fh <<'EOS'; |
| 34 | +#!/bin/sh |
| 35 | +
|
| 36 | +# Sourced from https://stackoverflow.com/a/29835459/1975049 |
| 37 | +rreadlink() ( |
| 38 | + target=$1 fname= targetDir= CDPATH= |
| 39 | + { \unalias command; \unset -f command; } >/dev/null 2>&1 |
| 40 | + [ -n "$ZSH_VERSION" ] && options[POSIX_BUILTINS]=on |
| 41 | + while :; do |
| 42 | + [ -L "$target" ] || [ -e "$target" ] || { command printf '%s\n' "ERROR: '$target' does not exist." >&2; return 1; } |
| 43 | + command cd "$(command dirname -- "$target")" |
| 44 | + fname=$(command basename -- "$target") |
| 45 | + [ "$fname" = '/' ] && fname='' |
| 46 | + if [ -L "$fname" ]; then |
| 47 | + target=$(command ls -l "$fname") |
| 48 | + target=${target#* -> } |
| 49 | + continue |
| 50 | + fi |
| 51 | + break |
| 52 | + done |
| 53 | + targetDir=$(command pwd -P) |
| 54 | + if [ "$fname" = '.' ]; then |
| 55 | + command printf '%s\n' "${targetDir%/}" |
| 56 | + elif [ "$fname" = '..' ]; then |
| 57 | + command printf '%s\n' "$(command dirname -- "${targetDir}")" |
| 58 | + else |
| 59 | + command printf '%s\n' "${targetDir%/}/$fname" |
| 60 | + fi |
| 61 | +) |
| 62 | +
|
| 63 | +DIR=$(dirname -- "$(rreadlink "$0")") |
44 | 64 |
|
45 | 65 | exec $DIR/moar --execname="$0" --libpath="$DIR/../share/nqp/lib" $DIR/../share/nqp/lib/nqp.moarvm "$@"
|
46 | 66 | EOS
|
|
0 commit comments