12

I am trying to make use of the minted package for source code highlighting, and am running into an error telling me I need to install pygmentize combined with an message regarding the --shell-escape flag.

I confirmed that running

$ xelatex --shell-escape my.tex

will compile correctly, but compilation via TexShop doesn't seem to be calling this flag and I cannot find a way to set it correctly. In the TexShop preferences, I did check that the pdfTeX commands have the --shell-escape flag set, but this does not seem to help or matter.

If someone could point out to me the way to inform TexShop about this flag for xelatex I'd be grateful.

15

You'll have a TeXShop Engines directory containing the shell scripts that are invoked whenever you hit the Typeset button. The script that's called depends which engine you have selected. For XeLaTeX it's usually ~/Library/TeXShop/Engines/XeLaTeX.engine by default.

It looks something like this:

#!/bin/tcsh

set path= ($path /Library/TeX/texbin /usr/texbin /usr/local/bin)
xelatex -file-line-error -synctex=1 "$1"

You can open it with a text editor and add the -shell-escape flag directly, like so:

#!/bin/tcsh

set path= ($path /Library/TeX/texbin /usr/texbin /usr/local/bin)
xelatex -file-line-error -synctex=1 -shell-escape "$1"

TeXShop will always call this script when XeLaTeX is selected, but you can save the changes to a new file, such as XeLaTeX-shellescape.engine. Both will appear in the menu and you'll be able to set the magic line to use this new script:

% !TEX TS-program = XeLaTeX-shellescape
  • awesome, that worked like a charm. as a follow-up, is there any downside to running it by default with the --shell-escape flag? – d7slaks87 Feb 24 '12 at 17:17
  • 1
    In case you receive a file from a non trusted source there are security risks. – egreg Feb 24 '12 at 17:21
  • Do you know if there's any way to tell TeX that the pygmentize command is safe to run, but not any of the others? Even that has security risks if somebody finds an arbitrary-code bug in pygmentize, but is still safer than "any command you want, including :(){ :|: & };: or rm -rf /*". – Daniel H Feb 13 '13 at 15:01
  • @DanielH minted checks for -shell-escape and refuses to work if it's not used. – egreg Feb 13 '13 at 15:47
  • 1
    I understand that; I was wondering if I could tell XeLaTeX to only allow a partial shell escape (and perhaps I'd have to modify minted if its check would be incompatible). Something like -shell-escape=pygmentize. I can't find anything about -shell-escape in the documentation of MikTex. Actually, I'm promoting this to a full question, as it's not particularly relevant here.. – Daniel H Feb 13 '13 at 17:51

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.