3
0
Fork 0
forked from mirrors/nixpkgs

texlive.combine: fix perl scripts without a shebang

Fixes #24343.  These parts of upstream texlive are really ugly.
Also improve variable quoting in the code around.
This commit is contained in:
Vladimír Čunát 2017-07-01 11:26:15 +02:00
parent 1551975e64
commit 8dddd2b672
No known key found for this signature in database
GPG key ID: E747DF1F9575A3AA

View file

@ -155,18 +155,24 @@ in buildEnv {
--prefix PERL5LIB : "$out/share/texmf/scripts/texlive"
# avoid using non-nix shebang in $target by calling interpreter
if [[ "$(head -c 2 $target)" = "#!" ]]; then
local cmdline="$(head -n 1 $target | sed 's/^\#\! *//;s/ *$//')"
if [[ "$(head -c 2 "$target")" = "#!" ]]; then
local cmdline="$(head -n 1 "$target" | sed 's/^\#\! *//;s/ *$//')"
local relative=`basename "$cmdline" | sed 's/^env //' `
local newInterp=`echo "$relative" | cut -d\ -f1`
local params=`echo "$relative" | cut -d\ -f2- -s`
local newPath="$(type -P $newInterp)"
local newPath="$(type -P "$newInterp")"
if [[ -z "$newPath" ]]; then
echo " Warning: unknown shebang '$cmdline' in '$target'"
continue
fi
echo " and patching shebang '$cmdline'"
sed "s|^exec |exec $newPath $params |" -i "$link"
elif head -n 1 "$target" | grep -q 'exec perl'; then
# see #24343 for details of the problem
echo " and patching weird perl shebang"
sed "s|^exec |exec '${perl}/bin/perl' -w |" -i "$link"
else
sed 's|^exec |exec -a "$0" |' -i "$link"
echo