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)
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
this software and associated documentation files (the "Software"), to deal in

View File

@ -3,7 +3,7 @@ pdflatex.sh
===========
:Author: Michał Kalewski
:Version: 3.3.1
:Version: 3.4.0
:License: MIT License
:Bug reports: https://github.com/mkalewski/pdflatex.sh/issues
@ -13,11 +13,11 @@ Synopsis
::
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 -gs | -rs | -gd | -rd DIR
pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s
| -ss | -sc [LANG] FILE(.tex)
pdflatex.sh -gs | -rs | -gd | -rd DIRECTORY
pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s | -ss
| -sc [LANG] FILE(.tex)
Description
===========
@ -68,7 +68,7 @@ Options
Put four pages of the PDF FILE on a single A4 sheet (the output will be in a
FILE-nup.pdf file).
``+3``
Run ``latex``/``pdflatex`` thrice (default is twice).
Run ``latex``/``pdflatex``/``xelatex`` thrice (default is twice).
``-b FILE``
Make ONLY BibTeX.
``+b``
@ -79,14 +79,14 @@ Options
Make ONLY glossaries (MakeGlossaries).
``+g``
Make ALSO glossaries (MakeGlossaries).
``-gs DIR``
Convert SVG images in directory DIR.
``-rs DIR``
Convert SVG images in directory DIR recursively.
``-gd DIR``
Convert DIA images in directory DIR.
``-rd DIR``
Convert DIA images in directory DIR recursively.
``-gs DIRECTORY``
Convert SVG images in directory DIRECTORY.
``-rs DIRECTORY``
Convert SVG images in directory DIRECTORY recursively.
``-gd DIRECTORY``
Convert DIA images in directory DIRECTORY.
``-rd DIRECTORY``
Convert DIA images in directory DIRECTORY recursively.
``-h``
Print the help message and exit.
``+h``
@ -110,7 +110,8 @@ Options
``+o``
Open the resulting PDF (or DVI) file after the compilation.
``+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``
Check sentence separators.
``+s``
@ -118,6 +119,9 @@ Options
``-sc [LANG] FILE``
Start the interactive ``aspell`` spell checker (by default ``LANG="en_GB"``
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``
STRICTLY check sentence separators.
``+sync``
@ -170,10 +174,12 @@ Examples
Copyright
=========
| (c) 2007-2015 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
| AND CONDITIONS OF THE MIT LICENSE. YOU SHOULD HAVE RECEIVED A COPY OF THE
| LICENSE ALONG WITH THIS SOFTWARE; IF NOT, YOU CAN DOWNLOAD A COPY FROM
| HTTP://WWW.OPENSOURCE.ORG.
```
(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
AND CONDITIONS OF THE MIT LICENSE. YOU SHOULD HAVE RECEIVED A COPY OF THE
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
# 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 IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE
@ -14,11 +14,11 @@
#
# SYNOPSIS
# 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 -gs | -rs | -gd | -rd DIR
# pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s
# | -ss | -sc [LANG] FILE(.tex)
# pdflatex.sh -gs | -rs | -gd | -rd DIRECTORY
# pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s | -ss
# | -sc [LANG] FILE(.tex)
#
# DESCRIPTION
# A bash script to simplify TeX/LaTeX/XeLaTeX files compilation and more.
@ -34,7 +34,7 @@
# VERSION
# =======
VERSION=3.3.1
VERSION=3.4.0
# PROGRAMS
@ -63,7 +63,7 @@ ASPELL_LANG_OPT="-l en_GB"
CHKTEX_OPT="-q -v1"
GREP_COLOR="--color=auto"
LATEX_BATCHMODE_OPT="-interaction batchmode"
#LATEX_OUTPUT_DIRECTORY_OPT="-output-directory"
LATEX_SHELL_ESCAPE_OPT="-shell-escape"
PDFLATEX_SYNCTEX_OPT="-synctex=1"
PDFNUP_OPT="--paper a4paper --frame true --scale 0.96 --delta \"2mm 2mm\""
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_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:
THENAME="$(basename $0)"
THEREALNAME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
@ -125,7 +128,7 @@ set +H
function print_help() {
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>
${txtund}A BASH SCRIPT TO SIMPLIFY TeX/LaTeX/XeLaTeX FILES COMPILATION\
@ -145,13 +148,13 @@ ${txtbld}Usage${txtrst}:
pdflatex.sh -h | -V
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.
pdflatex.sh -2x1 | -2x2 FILE(.pdf)
PDF documents manipulation.
pdflatex.sh -gs | -rs | -gd | -rd DIR
pdflatex.sh -gs | -rs | -gd | -rd DIRECTORY
Convert images.
pdflatex.sh -b | -c | -g | -i | -k | -kk | -l [WIDTH] | -n | -s | -ss
@ -159,44 +162,46 @@ ${txtbld}Usage${txtrst}:
Miscellaneous operations.
${txtbld}Options${txtrst}:
-2x1 FILE put two pages of the PDF FILE on a single A4 sheet
(the output will be in a FILE-nup.pdf file)
-2x2 FILE put four pages of the PDF FILE on a single A4 sheet
(the output will be in a FILE-nup.pdf file)
+3 run 'latex'/'pdflatex' thrice (default is twice)
-b FILE make ONLY BibTeX
+b make ALSO BibTeX
-c FILE cleanup (remove auxiliary files)
-g FILE make ONLY glossaries (MakeGlossaries)
+g make ALSO glossaries (MakeGlossaries)
-gs DIR convert SVG images in directory DIR
-rs DIR convert SVG images in directory DIR recursively
-gd DIR convert DIA images in directory DIR
-rd DIR convert DIA images in directory DIR recursively
-h print (this) help message and exit
+h make a handout from a beamer presentation, i.e., without
overlays, pauses, and other Beamer effects (the output
will be in a FILE-handout.pdf file)
-i FILE make ONLY index (MakeIndex)
+i make ALSO index (MakeIndex)
-k FILE run the 'chktex' command (if available)
-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
the given width (by default WIDTH=80)
-n FILE check non-breaking spaces
+n disable output coloring during the compilation
+o open the resulting PDF (or DVI) file after the
compilation
+p use 'ps4pdf' instead of 'pdflatex'/'latex' (PSTricks)
-s FILE check sentence separators
+s print a summary of problems (errors and warnings) after
the compilation
-sc [LANG] FILE start the interactive 'aspell' spell checker (by default
LANG="en_GB" and UTF-8 encoding is used)
-ss FILE STRICTLY check sentence separators
+sync enable the synchronization between the source file and
the resulting DVI or PDF file
-V print the script version
-2x1 FILE put two pages of the PDF FILE on a single A4 sheet (the
output will be in a FILE-nup.pdf file)
-2x2 FILE put four pages of the PDF FILE on a single A4 sheet (the
output will be in a FILE-nup.pdf file)
+3 run 'latex'/'pdflatex'/'xelatex' thrice (default is twice)
-b FILE make ONLY BibTeX
+b make ALSO BibTeX
-c FILE cleanup (remove auxiliary files)
-g FILE make ONLY glossaries (MakeGlossaries)
+g make ALSO glossaries (MakeGlossaries)
-gs DIRECTORY convert SVG images in directory DIRECTORY
-rs DIRECTORY convert SVG images in directory DIRECTORY recursively
-gd DIRECTORY convert DIA images in directory DIRECTORY
-rd DIRECTORY convert DIA images in directory DIRECTORY recursively
-h print (this) help message and exit
+h make a handout from a beamer presentation, i.e., without
overlays, pauses, and other Beamer effects (the output
will be in a FILE-handout.pdf file)
-i FILE make ONLY index (MakeIndex)
+i make ALSO index (MakeIndex)
-k FILE run the 'chktex' command (if available)
-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
the given width (by default WIDTH=80)
-n FILE check non-breaking spaces
+n disable output coloring during the compilation
+o open the resulting PDF (or DVI) file after the compilation
+p use 'ps4pdf' instead of 'latex'/'pdflatex'/'xelatex'
(the PSTricks package)
-s FILE check sentence separators
+s print a summary of problems (errors and warnings) after
the compilation
-sc [LANG] FILE start the interactive 'aspell' spell checker (by default
LANG="en_GB" and UTF-8 encoding is used)
+shell enable the shell escape option of 'latex'/'pdflatex'/
'xelatex'
-ss FILE STRICTLY check sentence separators
+sync enable the synchronization between the source file and the
resulting DVI or PDF file
-V print the script version
${txtbld}Examples${txtrst}:
pdflatex.sh file.tex
@ -423,12 +428,7 @@ function spell_checker() {
function run_pdflatex() {
check_programs "$GREP"
echo -ne "$TEXT..."
if [[ -n $APPENDSYNCTEX ]] ; then
$LATEX_PROGRAM $PDFLATEX_SYNCTEX_OPT $LATEX_BATCHMODE_OPT \
"$FILENAME" >&- 2>&-
else
$LATEX_PROGRAM $LATEX_BATCHMODE_OPT "$FILENAME" >&- 2>&-
fi
$LATEX_PROGRAM $LATEX_OPTIONS "$FILENAME" >&- 2>&-
local ERR=`$GREP -a -i error "$FILENAME".log | $GREP -a -v -i infwarerr`
if [[ -z $ERR ]] ; then
local ERR=`$GREP -a -i "^\!" "$FILENAME".log`
@ -496,8 +496,9 @@ while [[ -n $1 ]] ; do
-s) sentences "basic" "$2" ; exit 0 ;;
+s) SHOWSUMMARY="true" ; shift ;;
-sc) shift ; spell_checker "$@" ; break ;;
+shell) LATEX_OPTIONS="$LATEX_OPTIONS $LATEX_SHELL_ESCAPE_OPT" ; shift ;;
-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 ;;
-*) echo -ne "Unknown switch: ${txtylw}$1${txtrst}." ;
echo " Type: \"${txtbld}$THEREALNAME -h${txtrst}\" for help." ;
@ -638,13 +639,8 @@ for X in `seq 1 $THRICE` ; do
else
echo "${txtgrn}[done]${txtrst}"
echo -ne "$TEXT...\t\t\t\t"
if [[ -n $APPENDSYNCTEX ]] ; then
$LATEX_PROGRAM $PDFLATEX_SYNCTEX_OPT $LATEX_BATCHMODE_OPT \
"$PS4PDF_LATEX_OPT \input{$FILENAME}" >&- 2>&-
else
$LATEX_PROGRAM $LATEX_BATCHMODE_OPT "$PS4PDF_LATEX_OPT \
\input{$FILENAME}" >&- 2>&-
fi
$LATEX_PROGRAM $LATEX_OPTIONS "$PS4PDF_LATEX_OPT \
\input{$FILENAME}" >&- 2>&-
echo "${txtgrn}[done]${txtrst}"
AUXILIARYEXTS="$AUXILIARYEXTS log"
fi