2

I'm working on some experimental package that requires LaTeX to execute a Bash script. I'm aware of -shell-escape, etc., and it does work if I simply put the script next to the LaTeX file I'm compiling.

However, for distribution, it would be more convenient if I could just put the script into the same folder as the package (.sty) code and run it from there. Does LaTeX provide a way to add a package directory to its own shell search path?

  • 1
    in TeXlive there is /usr/local/texlive/2017/texmf-dist/scripts/ and I guess your script associated with package foo would be located in /usr/local/texlive/2017/texmf-dist/scripts/foo/. – user4686 Sep 25 '17 at 13:47
  • 1
    Disregard my previous comment: it’s misleading. As far as I can tell now, \write18 does not search for the command in any of the TeX input directories, it simply uses the (under UNIX-ish OS’s) the standard PATH environment variable. Even the scripts stored in the same directory as the .tex file executing them are not found unless . is part of the current PATH. There is no such thing as (La)TeX “own shell search path” (always AFAICT now). – GuM Sep 25 '17 at 19:09
4

You do know not everyone has Bash installed? :)

As jfbu says, it is better to arrange that it is installed into texlive's scripts directory (which will require some code review for security issues for example). However, if it is in the same directory as the .sty file you could call it via an explicit path built from kpsewhich mypackage.sty as in:

$ `dirname $(kpsewhich colortbl.sty)`/myscript
bash: /usr/local/texlive/2017/texmf-dist/tex/latex/colortbl/myscript: No such file or directory

Which tries (fails in this case) to run myscript from the colortbl directory.

  • Ah of course, kpsewhich to the rescue. And yes, I have heard that not everyone does have bash ;) but most of those people will have no use for the package anyway. But I will make a point of it in the docs. – Michael Palmer Sep 25 '17 at 14:07
  • 1
    @MichaelPalmer: See also the TEXMF_RESTRICTED_SCRIPTS variable in texmf.cnf. – GuM Sep 25 '17 at 14:24
  • @GuM - OK, thanks. The explanation is a bit sparse in that file, but I will experiment to find out what it means ;) – Michael Palmer Sep 25 '17 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.