Skip to content

Commit 8dddd2b

Browse files
committedJul 1, 2017
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.
1 parent 1551975 commit 8dddd2b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
 

‎pkgs/tools/typesetting/tex/texlive/combine.nix

+9-3
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,24 @@ in buildEnv {
155155
--prefix PERL5LIB : "$out/share/texmf/scripts/texlive"
156156
157157
# avoid using non-nix shebang in $target by calling interpreter
158-
if [[ "$(head -c 2 $target)" = "#!" ]]; then
159-
local cmdline="$(head -n 1 $target | sed 's/^\#\! *//;s/ *$//')"
158+
if [[ "$(head -c 2 "$target")" = "#!" ]]; then
159+
local cmdline="$(head -n 1 "$target" | sed 's/^\#\! *//;s/ *$//')"
160160
local relative=`basename "$cmdline" | sed 's/^env //' `
161161
local newInterp=`echo "$relative" | cut -d\ -f1`
162162
local params=`echo "$relative" | cut -d\ -f2- -s`
163-
local newPath="$(type -P $newInterp)"
163+
local newPath="$(type -P "$newInterp")"
164164
if [[ -z "$newPath" ]]; then
165165
echo " Warning: unknown shebang '$cmdline' in '$target'"
166166
continue
167167
fi
168168
echo " and patching shebang '$cmdline'"
169169
sed "s|^exec |exec $newPath $params |" -i "$link"
170+
171+
elif head -n 1 "$target" | grep -q 'exec perl'; then
172+
# see #24343 for details of the problem
173+
echo " and patching weird perl shebang"
174+
sed "s|^exec |exec '${perl}/bin/perl' -w |" -i "$link"
175+
170176
else
171177
sed 's|^exec |exec -a "$0" |' -i "$link"
172178
echo

0 commit comments

Comments
 (0)