patch-shebangs: handle env -S shebangs
`env -S` allows one to set more than one argument in a shebang. This small patch allows the patch-shebangs hook to handle this case appropriately.
This commit is contained in:
parent
ee54eb7d21
commit
792907e3bf
1 changed files with 10 additions and 4 deletions
|
@ -62,15 +62,21 @@ patchShebangs() {
|
|||
fi
|
||||
|
||||
if [[ "$oldPath" == *"/bin/env" ]]; then
|
||||
if [[ $arg0 == "-S" ]]; then
|
||||
arg0=${args%% *}
|
||||
args=${args#* }
|
||||
newPath="$(PATH="${!pathName}" command -v "env" || true)"
|
||||
args="-S $(PATH="${!pathName}" command -v "$arg0" || true) $args"
|
||||
|
||||
# Check for unsupported 'env' functionality:
|
||||
# - options: something starting with a '-'
|
||||
# - options: something starting with a '-' besides '-S'
|
||||
# - environment variables: foo=bar
|
||||
if [[ $arg0 == "-"* || $arg0 == *"="* ]]; then
|
||||
elif [[ $arg0 == "-"* || $arg0 == *"="* ]]; then
|
||||
echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" >&2
|
||||
exit 1
|
||||
else
|
||||
newPath="$(PATH="${!pathName}" command -v "$arg0" || true)"
|
||||
fi
|
||||
|
||||
newPath="$(PATH="${!pathName}" command -v "$arg0" || true)"
|
||||
else
|
||||
if [[ -z $oldPath ]]; then
|
||||
# If no interpreter is specified linux will use /bin/sh. Set
|
||||
|
|
Loading…
Reference in a new issue