Skip to content

Commit 275283a

Browse files
authored
Merge pull request #530 from patzim/no-bash
Don't use bash
2 parents e30aab6 + c5e843e commit 275283a

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

tools/build/Makefile-Moar.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ manifest:
7373

7474
release: manifest
7575
[ -n "$(VERSION)" ] || ( echo "\nTry 'make release VERSION=yyyy.mm'\n\n"; exit 1 )
76-
bash -c '[ "$$(cat VERSION)" == "$(VERSION)" ] || ( echo -e "\nVersion on command line and in VERSION file differ\n"; exit 1 )'
76+
sh -c '[ "$$(cat VERSION)" == "$(VERSION)" ] || ( echo -e "\nVersion on command line and in VERSION file differ\n"; exit 1 )'
7777
[ -d nqp-$(VERSION) ] || ln -s . nqp-$(VERSION)
7878
$(PERL) -ne 'print "nqp-$(VERSION)/$$_"' MANIFEST |\
7979
tar -zcv --owner=0 --group=0 --numeric-owner -T - -f nqp-$(VERSION).tar.gz

tools/build/install-moar-runner.pl

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,37 @@
3030
open my $fh, ">", $install_to
3131
or die "Could not open $install_to: $!";
3232
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")")
4464
4565
exec $DIR/moar --execname="$0" --libpath="$DIR/../share/nqp/lib" $DIR/../share/nqp/lib/nqp.moarvm "$@"
4666
EOS

0 commit comments

Comments
 (0)