sbang: Fix perl binary detection

The perl binary can also be called `perlX.Y.Z` if using a development
build or simply using the versioned binary.

We were also dropping all sbang arguments, since `exec $interpreter_v`
was only using the first element of the `interpreter_v` array.
This commit is contained in:
Michael Kuhn 2020-01-16 10:34:02 +01:00 committed by Peter Scheibel
parent 33d35768e6
commit 95ddd3d6f2

View file

@ -103,10 +103,10 @@ interpreter_f="${interpreter_v[0]}"
# Invoke any interpreter found, or raise an error if none was found.
if [[ -n "$interpreter_f" ]]; then
if [[ "${interpreter_f##*/}" = "perl" ]]; then
exec $interpreter_v -x "$@"
if [[ "${interpreter_f##*/}" = "perl"* ]]; then
exec $interpreter -x "$@"
else
exec $interpreter_v "$@"
exec $interpreter "$@"
fi
else
echo "error: sbang found no interpreter in $script"