#!/bin/sh

set -e
set -u

FINDBIN=$(cd -- "$(dirname "$0")" && pwd)
. "${FINDBIN}/common.sh"

cd "$BASEDIR"

usage() {
	echo "Usage: $0 <NAME>"
	exit 1
}

if [ -z "${1:-}" ]; then
	usage
fi

if [ -x "${BASEDIR}/sandbox/bin/$1" ]; then
	echo "# [dev/run] Found: ${BASEDIR}/sandbox/bin/$1"
	echo "# [dev/run] Command line: /usr/bin/perl -T -Mlib=${BASEDIR}/sandbox/lib/perl5/ ${BASEDIR}/sandbox/bin/$@"
	exec /usr/bin/perl -T -Mlib="${BASEDIR}/sandbox/lib/perl5/" "${BASEDIR}/sandbox/bin/$@"
else
	echo >&2 "Failed to find '$1'"
	exit 1
fi
