Add a new option: '+shell'.

The option enables the shell escape option of the
latex, pdflatex, and xelatex compilers.  It is
useful for packages like 'minted'.
This commit is contained in:
mkalewski 2016-01-26 21:16:24 +01:00
parent bdeb2a5575
commit de65176f9f
3 changed files with 87 additions and 85 deletions

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2007-2014 Michal Kalewski <mkalewski at cs.put.poznan.pl> Copyright (c) 2007-2016 Michal Kalewski <mkalewski at cs.put.poznan.pl>
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in

View File

@ -3,7 +3,7 @@ pdflatex.sh
=========== ===========
:Author: Michał Kalewski :Author: Michał Kalewski
:Version: 3.3.1 :Version: 3.4.0
:License: MIT License :License: MIT License
:Bug reports: https://github.com/mkalewski/pdflatex.sh/issues :Bug reports: https://github.com/mkalewski/pdflatex.sh/issues
@ -13,11 +13,11 @@ Synopsis
:: ::
pdflatex.sh -h | -V pdflatex.sh -h | -V
pdflatex.sh [ +3 +b +g +h +i +n +o +p +s +sync ] FILE(.tex) pdflatex.sh [ +3 +b +g +h +i +n +o +p +s +sync +shell ] FILE(.tex)
pdflatex.sh -2x1 | -2x2 FILE(.pdf) pdflatex.sh -2x1 | -2x2 FILE(.pdf)
pdflatex.sh -gs | -rs | -gd | -rd DIR pdflatex.sh -gs | -rs | -gd | -rd DIRECTORY
pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s | -ss
| -ss | -sc [LANG] FILE(.tex) | -sc [LANG] FILE(.tex)
Description Description
=========== ===========
@ -68,7 +68,7 @@ Options
Put four pages of the PDF FILE on a single A4 sheet (the output will be in a Put four pages of the PDF FILE on a single A4 sheet (the output will be in a
FILE-nup.pdf file). FILE-nup.pdf file).
``+3`` ``+3``
Run ``latex``/``pdflatex`` thrice (default is twice). Run ``latex``/``pdflatex``/``xelatex`` thrice (default is twice).
``-b FILE`` ``-b FILE``
Make ONLY BibTeX. Make ONLY BibTeX.
``+b`` ``+b``
@ -79,14 +79,14 @@ Options
Make ONLY glossaries (MakeGlossaries). Make ONLY glossaries (MakeGlossaries).
``+g`` ``+g``
Make ALSO glossaries (MakeGlossaries). Make ALSO glossaries (MakeGlossaries).
``-gs DIR`` ``-gs DIRECTORY``
Convert SVG images in directory DIR. Convert SVG images in directory DIRECTORY.
``-rs DIR`` ``-rs DIRECTORY``
Convert SVG images in directory DIR recursively. Convert SVG images in directory DIRECTORY recursively.
``-gd DIR`` ``-gd DIRECTORY``
Convert DIA images in directory DIR. Convert DIA images in directory DIRECTORY.
``-rd DIR`` ``-rd DIRECTORY``
Convert DIA images in directory DIR recursively. Convert DIA images in directory DIRECTORY recursively.
``-h`` ``-h``
Print the help message and exit. Print the help message and exit.
``+h`` ``+h``
@ -110,7 +110,8 @@ Options
``+o`` ``+o``
Open the resulting PDF (or DVI) file after the compilation. Open the resulting PDF (or DVI) file after the compilation.
``+p`` ``+p``
Use ``ps4pdf`` instead of ``pdflatex``/``latex`` (PSTricks). Use ``ps4pdf`` instead of ``latex``/``pdflatex``/``xelatex`` (the
`"PSTricks" <https://www.ctan.org/pkg/pstricks-base>`_ package).
``-s FILE`` ``-s FILE``
Check sentence separators. Check sentence separators.
``+s`` ``+s``
@ -118,6 +119,9 @@ Options
``-sc [LANG] FILE`` ``-sc [LANG] FILE``
Start the interactive ``aspell`` spell checker (by default ``LANG="en_GB"`` Start the interactive ``aspell`` spell checker (by default ``LANG="en_GB"``
and UTF-8 encoding is used). and UTF-8 encoding is used).
``+shell``
Enable the shell escape option of ``latex``/``pdflatex``/``xelatex`` (e.g.,
for the `"minted" <https://www.ctan.org/pkg/minted>`_ package).
``-ss FILE`` ``-ss FILE``
STRICTLY check sentence separators. STRICTLY check sentence separators.
``+sync`` ``+sync``
@ -170,10 +174,12 @@ Examples
Copyright Copyright
========= =========
| (c) 2007-2015 Michal Kalewski <mkalewski at cs.put.poznan.pl> ```
| (c) 2007-2016 Michal Kalewski <mkalewski at cs.put.poznan.pl>
| This program comes with ABSOLUTELY NO WARRANTY.
| THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE TERMS This program comes with ABSOLUTELY NO WARRANTY.
| AND CONDITIONS OF THE MIT LICENSE. YOU SHOULD HAVE RECEIVED A COPY OF THE THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE TERMS
| LICENSE ALONG WITH THIS SOFTWARE; IF NOT, YOU CAN DOWNLOAD A COPY FROM AND CONDITIONS OF THE MIT LICENSE. YOU SHOULD HAVE RECEIVED A COPY OF THE
| HTTP://WWW.OPENSOURCE.ORG. LICENSE ALONG WITH THIS SOFTWARE; IF NOT, YOU CAN DOWNLOAD A COPY FROM
HTTP://WWW.OPENSOURCE.ORG.
```

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# UTF-8 # UTF-8
# (c) 2007-2015 Michal Kalewski <mkalewski at cs.put.poznan.pl> # (c) 2007-2016 Michal Kalewski <mkalewski at cs.put.poznan.pl>
# #
# This program comes with ABSOLUTELY NO WARRANTY. # This program comes with ABSOLUTELY NO WARRANTY.
# THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE # THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE
@ -14,11 +14,11 @@
# #
# SYNOPSIS # SYNOPSIS
# pdflatex.sh -h | -V # pdflatex.sh -h | -V
# pdflatex.sh [ +3 +b +g +h +i +n +o +p +s +sync ] FILE(.tex) # pdflatex.sh [ +3 +b +g +h +i +n +o +p +s +sync +shell ] FILE(.tex)
# pdflatex.sh -2x1 | -2x2 FILE(.pdf) # pdflatex.sh -2x1 | -2x2 FILE(.pdf)
# pdflatex.sh -gs | -rs | -gd | -rd DIR # pdflatex.sh -gs | -rs | -gd | -rd DIRECTORY
# pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s # pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s | -ss
# | -ss | -sc [LANG] FILE(.tex) # | -sc [LANG] FILE(.tex)
# #
# DESCRIPTION # DESCRIPTION
# A bash script to simplify TeX/LaTeX/XeLaTeX files compilation and more. # A bash script to simplify TeX/LaTeX/XeLaTeX files compilation and more.
@ -34,7 +34,7 @@
# VERSION # VERSION
# ======= # =======
VERSION=3.3.1 VERSION=3.4.0
# PROGRAMS # PROGRAMS
@ -63,7 +63,7 @@ ASPELL_LANG_OPT="-l en_GB"
CHKTEX_OPT="-q -v1" CHKTEX_OPT="-q -v1"
GREP_COLOR="--color=auto" GREP_COLOR="--color=auto"
LATEX_BATCHMODE_OPT="-interaction batchmode" LATEX_BATCHMODE_OPT="-interaction batchmode"
#LATEX_OUTPUT_DIRECTORY_OPT="-output-directory" LATEX_SHELL_ESCAPE_OPT="-shell-escape"
PDFLATEX_SYNCTEX_OPT="-synctex=1" PDFLATEX_SYNCTEX_OPT="-synctex=1"
PDFNUP_OPT="--paper a4paper --frame true --scale 0.96 --delta \"2mm 2mm\"" PDFNUP_OPT="--paper a4paper --frame true --scale 0.96 --delta \"2mm 2mm\""
PS4PDF_LATEX_OPT="\AtBeginDocument{\RequirePackage{pst-pdf}}" PS4PDF_LATEX_OPT="\AtBeginDocument{\RequirePackage{pst-pdf}}"
@ -87,6 +87,9 @@ AUXILIARYEXTS_BIBTEX="$AUXILIARYEXTS_COMMON dvi gls ind pdf synctex.gz"
AUXILIARYEXTS_INDEX="$AUXILIARYEXTS_COMMON bbl div gls pdf synctex.gz" AUXILIARYEXTS_INDEX="$AUXILIARYEXTS_COMMON bbl div gls pdf synctex.gz"
AUXILIARYEXTS_GLOSSARIES="$AUXILIARYEXTS_COMMON bbl div ind pdf synctex.gz" AUXILIARYEXTS_GLOSSARIES="$AUXILIARYEXTS_COMMON bbl div ind pdf synctex.gz"
# Options to pass to the latex/pdflatex/xelatex compilers:
LATEX_OPTIONS="$LATEX_BATCHMODE_OPT"
# Base name of the script: # Base name of the script:
THENAME="$(basename $0)" THENAME="$(basename $0)"
THEREALNAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" THEREALNAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
@ -125,7 +128,7 @@ set +H
function print_help() { function print_help() {
cat <<EOF cat <<EOF
${txtbld}PDFLATEX.SH${txtrst} $VERSION (c) 2007-2015\ ${txtbld}PDFLATEX.SH${txtrst} $VERSION (c) 2007-2016\
${txtbld}Michal Kalewski${txtrst} <mkalewski at cs.put.poznan.pl> ${txtbld}Michal Kalewski${txtrst} <mkalewski at cs.put.poznan.pl>
${txtund}A BASH SCRIPT TO SIMPLIFY TeX/LaTeX/XeLaTeX FILES COMPILATION\ ${txtund}A BASH SCRIPT TO SIMPLIFY TeX/LaTeX/XeLaTeX FILES COMPILATION\
@ -145,13 +148,13 @@ ${txtbld}Usage${txtrst}:
pdflatex.sh -h | -V pdflatex.sh -h | -V
Print help or version. Print help or version.
pdflatex.sh [ +3 +b +g +h +i +n +o +p +s +sync ] FILE(.tex) pdflatex.sh [ +3 +b +g +h +i +n +o +p +s +sync +shell ] FILE(.tex)
Compile (La)TeX files. Compile (La)TeX files.
pdflatex.sh -2x1 | -2x2 FILE(.pdf) pdflatex.sh -2x1 | -2x2 FILE(.pdf)
PDF documents manipulation. PDF documents manipulation.
pdflatex.sh -gs | -rs | -gd | -rd DIR pdflatex.sh -gs | -rs | -gd | -rd DIRECTORY
Convert images. Convert images.
pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s | -ss pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s | -ss
@ -159,44 +162,46 @@ ${txtbld}Usage${txtrst}:
Miscellaneous operations. Miscellaneous operations.
${txtbld}Options${txtrst}: ${txtbld}Options${txtrst}:
-2x1 FILE put two pages of the PDF FILE on a single A4 sheet -2x1 FILE put two pages of the PDF FILE on a single A4 sheet (the
(the output will be in a FILE-nup.pdf file) output will be in a FILE-nup.pdf file)
-2x2 FILE put four pages of the PDF FILE on a single A4 sheet -2x2 FILE put four pages of the PDF FILE on a single A4 sheet (the
(the output will be in a FILE-nup.pdf file) output will be in a FILE-nup.pdf file)
+3 run 'latex'/'pdflatex' thrice (default is twice) +3 run 'latex'/'pdflatex'/'xelatex' thrice (default is twice)
-b FILE make ONLY BibTeX -b FILE make ONLY BibTeX
+b make ALSO BibTeX +b make ALSO BibTeX
-c FILE cleanup (remove auxiliary files) -c FILE cleanup (remove auxiliary files)
-g FILE make ONLY glossaries (MakeGlossaries) -g FILE make ONLY glossaries (MakeGlossaries)
+g make ALSO glossaries (MakeGlossaries) +g make ALSO glossaries (MakeGlossaries)
-gs DIR convert SVG images in directory DIR -gs DIRECTORY convert SVG images in directory DIRECTORY
-rs DIR convert SVG images in directory DIR recursively -rs DIRECTORY convert SVG images in directory DIRECTORY recursively
-gd DIR convert DIA images in directory DIR -gd DIRECTORY convert DIA images in directory DIRECTORY
-rd DIR convert DIA images in directory DIR recursively -rd DIRECTORY convert DIA images in directory DIRECTORY recursively
-h print (this) help message and exit -h print (this) help message and exit
+h make a handout from a beamer presentation, i.e., without +h make a handout from a beamer presentation, i.e., without
overlays, pauses, and other Beamer effects (the output overlays, pauses, and other Beamer effects (the output
will be in a FILE-handout.pdf file) will be in a FILE-handout.pdf file)
-i FILE make ONLY index (MakeIndex) -i FILE make ONLY index (MakeIndex)
+i make ALSO index (MakeIndex) +i make ALSO index (MakeIndex)
-k FILE run the 'chktex' command (if available) -k FILE run the 'chktex' command (if available)
-kk FILE the same as '-k' but only errors are shown -kk FILE the same as '-k' but only errors are shown
-l [WIDTH] FILE check if the length of each line in FILE does not exceed -l [WIDTH] FILE check if the length of each line in FILE does not exceed
the given width (by default WIDTH=80) the given width (by default WIDTH=80)
-n FILE check non-breaking spaces -n FILE check non-breaking spaces
+n disable output coloring during the compilation +n disable output coloring during the compilation
+o open the resulting PDF (or DVI) file after the +o open the resulting PDF (or DVI) file after the compilation
compilation +p use 'ps4pdf' instead of 'latex'/'pdflatex'/'xelatex'
+p use 'ps4pdf' instead of 'pdflatex'/'latex' (PSTricks) (the PSTricks package)
-s FILE check sentence separators -s FILE check sentence separators
+s print a summary of problems (errors and warnings) after +s print a summary of problems (errors and warnings) after
the compilation the compilation
-sc [LANG] FILE start the interactive 'aspell' spell checker (by default -sc [LANG] FILE start the interactive 'aspell' spell checker (by default
LANG="en_GB" and UTF-8 encoding is used) LANG="en_GB" and UTF-8 encoding is used)
-ss FILE STRICTLY check sentence separators +shell enable the shell escape option of 'latex'/'pdflatex'/
+sync enable the synchronization between the source file and 'xelatex'
the resulting DVI or PDF file -ss FILE STRICTLY check sentence separators
-V print the script version +sync enable the synchronization between the source file and the
resulting DVI or PDF file
-V print the script version
${txtbld}Examples${txtrst}: ${txtbld}Examples${txtrst}:
pdflatex.sh file.tex pdflatex.sh file.tex
@ -423,12 +428,7 @@ function spell_checker() {
function run_pdflatex() { function run_pdflatex() {
check_programs "$GREP" check_programs "$GREP"
echo -ne "$TEXT..." echo -ne "$TEXT..."
if [[ -n $APPENDSYNCTEX ]] ; then $LATEX_PROGRAM $LATEX_OPTIONS "$FILENAME" >&- 2>&-
$LATEX_PROGRAM $PDFLATEX_SYNCTEX_OPT $LATEX_BATCHMODE_OPT \
"$FILENAME" >&- 2>&-
else
$LATEX_PROGRAM $LATEX_BATCHMODE_OPT "$FILENAME" >&- 2>&-
fi
local ERR=`$GREP -a -i error "$FILENAME".log | $GREP -a -v -i infwarerr` local ERR=`$GREP -a -i error "$FILENAME".log | $GREP -a -v -i infwarerr`
if [[ -z $ERR ]] ; then if [[ -z $ERR ]] ; then
local ERR=`$GREP -a -i "^\!" "$FILENAME".log` local ERR=`$GREP -a -i "^\!" "$FILENAME".log`
@ -496,8 +496,9 @@ while [[ -n $1 ]] ; do
-s) sentences "basic" "$2" ; exit 0 ;; -s) sentences "basic" "$2" ; exit 0 ;;
+s) SHOWSUMMARY="true" ; shift ;; +s) SHOWSUMMARY="true" ; shift ;;
-sc) shift ; spell_checker "$@" ; break ;; -sc) shift ; spell_checker "$@" ; break ;;
+shell) LATEX_OPTIONS="$LATEX_OPTIONS $LATEX_SHELL_ESCAPE_OPT" ; shift ;;
-ss) sentences "strict" "$2" ; exit 0 ;; -ss) sentences "strict" "$2" ; exit 0 ;;
+sync) APPENDSYNCTEX="true" ; shift ;; +sync) LATEX_OPTIONS="$LATEX_OPTIONS $PDFLATEX_SYNCTEX_OPT" ; shift ;;
-[vV]) echo "$THEREALNAME $VERSION" ; echo ; exit 0 ;; -[vV]) echo "$THEREALNAME $VERSION" ; echo ; exit 0 ;;
-*) echo -ne "Unknown switch: ${txtylw}$1${txtrst}." ; -*) echo -ne "Unknown switch: ${txtylw}$1${txtrst}." ;
echo " Type: \"${txtbld}$THEREALNAME -h${txtrst}\" for help." ; echo " Type: \"${txtbld}$THEREALNAME -h${txtrst}\" for help." ;
@ -638,13 +639,8 @@ for X in `seq 1 $THRICE` ; do
else else
echo "${txtgrn}[done]${txtrst}" echo "${txtgrn}[done]${txtrst}"
echo -ne "$TEXT...\t\t\t\t" echo -ne "$TEXT...\t\t\t\t"
if [[ -n $APPENDSYNCTEX ]] ; then $LATEX_PROGRAM $LATEX_OPTIONS "$PS4PDF_LATEX_OPT \
$LATEX_PROGRAM $PDFLATEX_SYNCTEX_OPT $LATEX_BATCHMODE_OPT \ \input{$FILENAME}" >&- 2>&-
"$PS4PDF_LATEX_OPT \input{$FILENAME}" >&- 2>&-
else
$LATEX_PROGRAM $LATEX_BATCHMODE_OPT "$PS4PDF_LATEX_OPT \
\input{$FILENAME}" >&- 2>&-
fi
echo "${txtgrn}[done]${txtrst}" echo "${txtgrn}[done]${txtrst}"
AUXILIARYEXTS="$AUXILIARYEXTS log" AUXILIARYEXTS="$AUXILIARYEXTS log"
fi fi