Skip to content

Instantly share code, notes, and snippets.

@samcv
Last active April 10, 2017 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/bc009f92a764fffe8f2571f0d34e3bb2 to your computer and use it in GitHub Desktop.
Save samcv/bc009f92a764fffe8f2571f0d34e3bb2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#Get the directory you ran the script from
IMAGE_PWD="$(pwd)"
cd "$OWD"
i=$(($#-1))
function argv {
for a in "${BASH_ARGV[*]}" ; do
arg="$a"
if [ "$APPIMAGE_DEBUG" ]; then printf "Got Arg: %s is ‘%s’\n" "$i" "$arg" 1>&2; fi
first_letter=$(printf %.1s "$arg")
#if [ "$arg" == "--output="]; then SKIP_NEXT=1; fi
if [[ "$arg" == "-e" || "$arg" == "--output=" ]]; then SKIP_NEXT=1; fi
if [[ $first_letter != '-' && !$SKIP_NEXT ]]; then
arg=$(readlink -f "$arg")
fi
NEWARGS[$i]="$arg"
i=$((i-1))
done
}
argv
function debug {
temp_j=0
for a in "${NEWARGS[*]}" ; do
printf "Passing on Arg $temp_j is ‘%s’\n" "$a" 1>&2
temp_j=$((temp_j+1))
done
if [ $temp_j == 0 ]; then echo "Did not see any command line args" 1>&2; fi
}
if [ "$APPIMAGE_DEBUG" ]; then debug; fi
cd "$IMAGE_PWD"
exec ./bin/moar --execname="$0" --libpath="./share/nqp/lib" --libpath="./share/nqp/lib" \
--libpath="./share/perl6/lib" \
--libpath="./share/perl6/runtime" \
././share/perl6/runtime/perl6.moarvm \
"${NEWARGS[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment