larskotthoff / gnuplottex

Gnuplot graphs in LaTeX. See http://www.ctan.org/pkg/gnuplottex
3 stars 1 forks source link

Subfolder is ignored with shell escape disabled #12

Closed aserenko closed 4 years ago

aserenko commented 4 years ago

Checking write access to the subfolder is currently implemented involving \write18. Thus, in the environment with shell escape disabled, it falls back to not using the subfolder even if the latter exists. This contradicts the warning wording "You'll need to create the folder yourself", because creating the folder manually won't be of any help in such a case.

I believe it would be much better, if possible, to implement lines https://github.com/larskotthoff/gnuplottex/blob/90a25d624218d14e67547ecdab6975bd00909e26/gnuplottex.dtx#L712 and https://github.com/larskotthoff/gnuplottex/blob/90a25d624218d14e67547ecdab6975bd00909e26/gnuplottex.dtx#L715 in some way without \write18. My use case, which I believe to be quite natural, is to disable shell-escape when one wants to use pre-generated figures to save time (and I do it by passing --no-shell-escape to latex rather than by changing shell option in \include{gnuplottex} back and forth).

larskotthoff commented 4 years ago

Thanks for the report -- I don't think that this can be implemented without write18 as it requires to test whether an external file can be created. Any suggestions appreciated though!

aserenko commented 4 years ago

Oh, another related question: what if \write18 is enabled but gnuplottex is given options noshell, subfolder? In this case, it still tries to create the subfolder but complains about \tmpfile undefined: https://github.com/larskotthoff/gnuplottex/blob/90a25d624218d14e67547ecdab6975bd00909e26/gnuplottex.dtx#L693

Do you think the definition of \tmpfile should be moved outside of \ifShellEscape, or maybe the other way round, the subfolder checking code should be conditioned on \ifShellEscape?

larskotthoff commented 4 years ago

Ah yes, this should be conditioned on shell escape being enabled.

aserenko commented 4 years ago

Sorry for a possibly silly question, but why can't we just say

\immediate\openout\tmpfiledescriptor=\gnuplottex/\tmpfile
\immediate\write\tmpfiledescriptor{test}
\immediate\closeout\tmpfiledescriptor

instead of those \write18 in lines 712 and 715? I mean, in those lines we just check if gnuplottex/ is accessible, while shell escape is a totally unrelated check performed earlier.

aserenko commented 4 years ago

Also, what is the purpose of the dot here? https://github.com/larskotthoff/gnuplottex/blob/90a25d624218d14e67547ecdab6975bd00909e26/gnuplottex.dtx#L700 I am not that experienced in latex, but I fail to find it anywhere else in \IfFileExists commands.

larskotthoff commented 4 years ago

That last one is probably a typo. To test whether the directory is accessible, we need shell escape enabled to see if we can create files there.

larskotthoff commented 4 years ago

I've just pushed a fix for this -- sorry it took so long. Could you check whether this works for you please? I'll make a new release then.

larskotthoff commented 4 years ago

New release on CTAN -- please reopen if any issues remain.