Skip to content

Commit

Permalink
Merge pull request #22 from xqms/bugfix/shellescape16
Browse files Browse the repository at this point in the history
Remove shellesc dependency (it is buggy on Ubuntu 16.04 / TeXLive 2015)
  • Loading branch information
xqms authored Dec 20, 2022
2 parents 26f5c7c + a4d1bf0 commit 9f9debd
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions graphicscache.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@
\RequirePackage{ifplatform}
\RequirePackage{pdftexcmds}
\RequirePackage{ltxcmds}
\RequirePackage{shellesc}
\newif\ifgraphicscache@render
\newif\ifgraphicscache@compress
\newif\ifgraphicscache@listing
Expand Down Expand Up @@ -312,14 +311,23 @@
\newwrite\graphicscache@listout
\immediate\openout\graphicscache@listout=\jobname.graphicscache
\fi
%
% shellesc has a bug on Ubuntu 16.04 (\ShellEscape is not immediate).
% So we simply define our own shellescape macro.
\ifx\lastsavedimageresourcepages\@undefined
\protected\def\graphicscache@ShellEscape{\immediate\write18 }
\else
\protected\def\graphicscache@ShellEscape#1{%
\directlua{os.execute("\luaescapestring{#1}")}}
\fi
% \end{macrocode}
%
% \begin{macro}{\graphicscache@callgswithname}
% This macro calls ghostscript using the name specified in the first argument.
% \begin{macrocode}
\newcommand{\graphicscache@callgswithname}[1]{%
\ifwindows
\ShellEscape{#1
\graphicscache@ShellEscape{#1
-sOutputFile=\graphicscache@output\space
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.4
Expand All @@ -340,7 +348,7 @@
-f \graphicscache@cachedir\string\graphicscacheout.pdf
}%
\else
\ShellEscape{#1
\graphicscache@ShellEscape{#1
-sOutputFile=\graphicscache@output\space
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.4
Expand Down Expand Up @@ -402,16 +410,16 @@
\newcommand{\graphicscache@dorender}{%
\PackageInfo{graphicscache}{Rendering \graphicscache@outputhash: \graphicscache@fname\space with args: \graphicscache@graphicsargs\space (master file)}%
\ifwindows
\ShellEscape{md "\graphicscache@cachedir" 2>NUL}%
\graphicscache@ShellEscape{md "\graphicscache@cachedir" 2>NUL}%
\else
\ShellEscape{mkdir -p "\graphicscache@cachedir"}%
\graphicscache@ShellEscape{mkdir -p "\graphicscache@cachedir"}%
\fi
% \end{macrocode}
% First, render the graphics.
% \begin{macrocode}
\ifwindows
\ShellEscape{del /q \graphicscache@cachedir\string\graphicscacheout.pdf}
\ShellEscape{pdflatex
\graphicscache@ShellEscape{del /q \graphicscache@cachedir\string\graphicscacheout.pdf}
\graphicscache@ShellEscape{pdflatex
-jobname graphicscacheout
-interaction nonstopmode
-output-directory "\graphicscache@cachedir"
Expand All @@ -425,7 +433,7 @@
\def\graphicscache@output{}%
}
\else
\ShellEscape{pdflatex
\graphicscache@ShellEscape{pdflatex
-jobname graphicscacheout
-interaction nonstopmode
-output-directory "\graphicscache@cachedir"
Expand All @@ -446,11 +454,11 @@
\else
\PackageInfo{graphicscache}{Direct}%
\ifwindows
\ShellEscape{
\graphicscache@ShellEscape{
copy \graphicscache@cachedir\string\graphicscacheout.pdf \graphicscache@output
}%
\else
\ShellEscape{
\graphicscache@ShellEscape{
cp \graphicscache@cachedir/graphicscacheout.pdf \graphicscache@output
}%
\fi
Expand Down

0 comments on commit 9f9debd

Please sign in to comment.