From af94f399b2a355396d222eb693423beb6294a683 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 5 May 2017 22:50:09 +0000 Subject: texosquery (5may17) git-svn-id: svn://tug.org/texlive/trunk@44216 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/support/texosquery/CHANGES | 13 + Master/texmf-dist/doc/support/texosquery/README.md | 36 +- .../doc/support/texosquery/texosquery.pdf | Bin 490471 -> 499507 bytes .../scripts/texosquery/texosquery-jre5.jar | Bin 62917 -> 62916 bytes .../scripts/texosquery/texosquery-jre5.sh | 1 + .../scripts/texosquery/texosquery-jre8.jar | Bin 67247 -> 67211 bytes .../scripts/texosquery/texosquery-jre8.sh | 1 + .../texmf-dist/scripts/texosquery/texosquery.jar | Bin 66196 -> 66194 bytes Master/texmf-dist/scripts/texosquery/texosquery.sh | 1 + .../source/support/texosquery/java/TeXOSQuery.java | 4 +- .../support/texosquery/java/TeXOSQueryJRE8.java | 15 +- .../support/texosquery/texosquery-jre5.batch | 1 + .../support/texosquery/texosquery-jre8.batch | 1 + .../source/support/texosquery/texosquery.batch | 1 + .../source/support/texosquery/texosquery.dtx | 835 ++++++++++++++------- .../source/support/texosquery/texosquery.ins | 9 +- .../texmf-dist/tex/latex/texosquery/texosquery.cfg | 85 +-- .../texmf-dist/tex/latex/texosquery/texosquery.sty | 3 +- .../texmf-dist/tex/latex/texosquery/texosquery.tex | 231 +++++- 19 files changed, 852 insertions(+), 385 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/support/texosquery/CHANGES b/Master/texmf-dist/doc/support/texosquery/CHANGES index eae2c455b22..4c143633004 100644 --- a/Master/texmf-dist/doc/support/texosquery/CHANGES +++ b/Master/texmf-dist/doc/support/texosquery/CHANGES @@ -1,3 +1,16 @@ +1.4 (2017/05/05): + + * The fallback value for 'openin_any' for texosquery-jre8 + is now 'a' if unset. + + * Added clearer instructions in texosquery.cfg and information + messages to the transcript. + + * Added \TeXOSQueryFromFile. + + * Shortcut commands only use quotes to delimit arguments + in the unrestricted mode. + 1.3 (2017/03/31): * If 'openin_any' hasn't been set, the fallback value for diff --git a/Master/texmf-dist/doc/support/texosquery/README.md b/Master/texmf-dist/doc/support/texosquery/README.md index c9f883ee00b..ce37682eddb 100644 --- a/Master/texmf-dist/doc/support/texosquery/README.md +++ b/Master/texmf-dist/doc/support/texosquery/README.md @@ -38,6 +38,36 @@ temporarily changed to 12 while reading the result. Some of the `texosquery` output contains short markup commands (such as `\wrp`) which are internally converted within `\TeXOSQuery`. +## Important Notes + +The TeX code uses a piped shell escape to capture the result from +`texosquery`. This means that you must have the piped shell escape +enabled to make use of this feature. MiKTeX users need the +`--enable-pipes` option on the TeX command line to enable this. +The alternative is to run `texosquery` outside of TeX and +capture the output in a temporary file, which can then be +read using `\TeXOSQueryFromFile`. + +You need to correctly set up the configuration file `texosquery.cfg` +to match your system. The TeX package managers can't do this for you +automatically. Copy the file to either your `TEXMFHOME` or +`TEXMFLOCAL` tree to prevent it from being overwritten by subsequent +updates. + +`texosquery-jre8` is on the restricted list for TeX Live 2017. To +take advantage of this, you must have at least Java 8 installed and +edit the `texosquery.cfg` file to: +```tex +\def\TeXOSInvokerName{texosquery-jre8} +\TeXOSQueryAllowRestricted +``` +(Note that the second line above has been uncommented.) + +Note that due to TeX's security measures, quotes can't be used in the +restricted mode's shell escape. This means that if you need to pass +a file name containing a space as an argument to `texosquery`, +you'll have to use the unrestricted mode. + ## Installation Installation is best done using your TeX package manager. @@ -282,9 +312,11 @@ or a security exception.) ## Security As from version 1.2, all variants of `texosquery` (JRE5, 7 and 8) -obey TeX's `openin_any` setting. Any of the actions that involve +obey TeX Live's `openin_any` setting. Any of the actions that involve reading file information won't work if read access is forbidden by -`openin_any` or by the operating system. +`openin_any` or by the operating system. MiKTeX doesn't use the +`openin_any` setting, so if not set `texosquery` will assume `a` +(any). In addition to obeying `openin_any`, the file listing actions (such as `--list`) for the JRE7 and 8 variants also prohibit listing the diff --git a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf index 7cb09b482af..92b576339ee 100644 Binary files a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf and b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar index cddc5b057ac..d5155d40690 100755 Binary files a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar and b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.jar differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh index 67a402279b5..e841a0ea7d2 100755 --- a/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh +++ b/Master/texmf-dist/scripts/texosquery/texosquery-jre5.sh @@ -1,4 +1,5 @@ #!/bin/sh + jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre5.jar` java -jar "$jarpath" "$@" diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar index 3693b345148..6c1090e737d 100755 Binary files a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar and b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.jar differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh index 472c531453a..d13f8eeff5a 100755 --- a/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh +++ b/Master/texmf-dist/scripts/texosquery/texosquery-jre8.sh @@ -1,4 +1,5 @@ #!/bin/sh + jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre8.jar` java -Djava.locale.providers=CLDR,JRE -jar "$jarpath" "$@" diff --git a/Master/texmf-dist/scripts/texosquery/texosquery.jar b/Master/texmf-dist/scripts/texosquery/texosquery.jar index 667cc7cf8fc..cff38782dae 100755 Binary files a/Master/texmf-dist/scripts/texosquery/texosquery.jar and b/Master/texmf-dist/scripts/texosquery/texosquery.jar differ diff --git a/Master/texmf-dist/scripts/texosquery/texosquery.sh b/Master/texmf-dist/scripts/texosquery/texosquery.sh index 2f97a43db65..db9f8addfab 100755 --- a/Master/texmf-dist/scripts/texosquery/texosquery.sh +++ b/Master/texmf-dist/scripts/texosquery/texosquery.sh @@ -1,4 +1,5 @@ #!/bin/sh + jarpath=`kpsewhich --progname=texosquery --format=texmfscripts texosquery.jar` java -jar "$jarpath" "$@" diff --git a/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java b/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java index cf1f59d12bf..5e371b56ab2 100644 --- a/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java +++ b/Master/texmf-dist/source/support/texosquery/java/TeXOSQuery.java @@ -4312,8 +4312,8 @@ public class TeXOSQuery implements Serializable public static final int DEFAULT_COMPATIBLE=2; - private static final String VERSION_NUMBER = "1.3"; - private static final String VERSION_DATE = "2017-03-31"; + private static final String VERSION_NUMBER = "1.4"; + private static final String VERSION_DATE = "2017-05-05"; private static final char BACKSLASH = '\\'; private static final long ZERO = 0L; diff --git a/Master/texmf-dist/source/support/texosquery/java/TeXOSQueryJRE8.java b/Master/texmf-dist/source/support/texosquery/java/TeXOSQueryJRE8.java index 02b28fe726f..5884fb9d63a 100644 --- a/Master/texmf-dist/source/support/texosquery/java/TeXOSQueryJRE8.java +++ b/Master/texmf-dist/source/support/texosquery/java/TeXOSQueryJRE8.java @@ -33,15 +33,12 @@ public class TeXOSQueryJRE8 extends TeXOSQuery super("texosquery-jre8"); } - /** - * Fallback for openin_any if not found. - * @since 1.2.2 - * @Override - */ - public char openinFallbackValue() - { - return OPENIN_P; - } + /* + * The fallback for openin_any is now the same for + * all variants to allow texosquery-jre8 to work with MiKTeX + * so openinFallbackValue method has been removed from this + * subclass in v1.3.1. + */ /** * Converts the given directory to a canonical path diff --git a/Master/texmf-dist/source/support/texosquery/texosquery-jre5.batch b/Master/texmf-dist/source/support/texosquery/texosquery-jre5.batch index 9202bbf8746..b86fc44aa32 100644 --- a/Master/texmf-dist/source/support/texosquery/texosquery-jre5.batch +++ b/Master/texmf-dist/source/support/texosquery/texosquery-jre5.batch @@ -1,4 +1,5 @@ + @ECHO OFF FOR /F "tokens=*" %%I IN ('kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre5.jar') DO SET JARPATH=%%I java -jar "%JARPATH%" %* diff --git a/Master/texmf-dist/source/support/texosquery/texosquery-jre8.batch b/Master/texmf-dist/source/support/texosquery/texosquery-jre8.batch index 050a50eb600..649f0fd5b35 100644 --- a/Master/texmf-dist/source/support/texosquery/texosquery-jre8.batch +++ b/Master/texmf-dist/source/support/texosquery/texosquery-jre8.batch @@ -1,4 +1,5 @@ + @ECHO OFF FOR /F "tokens=*" %%I IN ('kpsewhich --progname=texosquery --format=texmfscripts texosquery-jre8.jar') DO SET JARPATH=%%I java -Djava.locale.providers=CLDR,JRE -jar "%JARPATH%" %* diff --git a/Master/texmf-dist/source/support/texosquery/texosquery.batch b/Master/texmf-dist/source/support/texosquery/texosquery.batch index 41b7d00bc0b..1cb09c87c9a 100644 --- a/Master/texmf-dist/source/support/texosquery/texosquery.batch +++ b/Master/texmf-dist/source/support/texosquery/texosquery.batch @@ -1,4 +1,5 @@ + @ECHO OFF FOR /F "tokens=*" %%I IN ('kpsewhich --progname=texosquery --format=texmfscripts texosquery.jar') DO SET JARPATH=%%I java -jar "%JARPATH%" %* diff --git a/Master/texmf-dist/source/support/texosquery/texosquery.dtx b/Master/texmf-dist/source/support/texosquery/texosquery.dtx index 7f0e3742dfc..b3ec60201a0 100644 --- a/Master/texmf-dist/source/support/texosquery/texosquery.dtx +++ b/Master/texmf-dist/source/support/texosquery/texosquery.dtx @@ -53,7 +53,7 @@ \renewcommand{\meta@font@select}{\rmfamily\itshape} \makeatother -\CheckSum{3292} +\CheckSum{3469} \RecordChanges \PageIndex @@ -65,6 +65,8 @@ \renewcommand*{\usage}[1]{\hyperpage{#1}} \renewcommand*{\main}[1]{\hyperpage{#1}} +\newcommand*{\ics}[1]{\cs{#1}\SpecialMainIndex{#1}} + \newcommand*{\qt}[1]{``#1''} \newcommand*{\sty}[1]{\textsf{#1}} \newcommand*{\app}[1]{\texttt{#1}} @@ -123,7 +125,7 @@ Organization for Standardization} %\author{Nicola L. C. Talbot\\ %\href{http://www.dickimaw-books.com/}{\nolinkurl{dickimaw-books.com}} %\and Paulo Cereda} -%\date{2017-03-31 (v1.3)} +%\date{2017-05-05 (v1.4)} %\maketitle % %\begin{abstract} @@ -148,8 +150,13 @@ Organization for Standardization} %\end{abstract} % %\begin{important} -%You will need \TeX's shell escape enabled, +%You will need \TeX's piped shell escape enabled %and you will also need the \gls{JRE} installed. +%MiKTeX users will need to add \verb|--enable-pipes| to TeX's +%command line options. (Alternatively, use \cs{TeXOSQueryFromFile} +%if you can't use the piped shell escape.) +%The configuration file \hyperref[itm:cfg]{\file{texosquery.cfg}} +%should be edited to reflect your system set-up before use. %\end{important} % %There are three variations of the \app{texosquery} application provided: @@ -370,13 +377,16 @@ Organization for Standardization} % %Even if you use your \TeX\ distribution's package manager to %install this package, you may still need to edit the -%\file{texosquery.cfg} file (see step~\ref{itm:cfg} below). If you don't have write permission for -%this file you can copy it to \meta{TEXMFHOME}\file{/tex/generic/texosquery/} -%(that directory path may need to be created if it doesn't already -%exist). You can find the correct value of \meta{TEXMFHOME} using +%\file{texosquery.cfg} file (see step~\ref{itm:cfg} below). It's +%best to copy this file to your \meta{TEXMFHOME} or \meta{TEXMFLOCAL} +%tree to avoid losing your changes when the package is updated. + +%You can find the correct value of \meta{TEXMFHOME} using %\begin{verbatim} %kpsewhich -var-value=TEXMFHOME %\end{verbatim} +%Similarly for \meta{TEXMFLOCAL}. +% %You can find where the package manager has put \file{texosquery.cfg} using %\begin{verbatim} %kpsewhich texosquery.cfg @@ -549,19 +559,15 @@ Organization for Standardization} %used. Check that the \longarg{shell-escape} switch was used when %calling \app{pdftex} or \app{pdflatex}. % -%If you are using \app{texosquery} or \app{texosquery-jre8} and your -%chosen application has been added to the restricted list, make sure +%\TeX\ Live 2017 has added \app{texosquery-jre8} to the restricted +%list, but you need to modify the configuration file to take +%advantage of this. Make sure %that the line %\begin{verbatim} %\TeXOSQueryAllowRestricted %\end{verbatim} %hasn't been commented out in the \file{texosquery.cfg} file and try -%the above example documents in restricted mode. (Note that -%\app{texosquery-jre5} should not be added to the restricted list as -%Java 5 and 6 are now deprecated and considered security risks, so -%the above command should be commented out in the -%\file{texosquery.cfg} file if \cs{TeXOSInvokerName} has been set to -%\app{texosquery-jre5}.) +%the above example documents in restricted mode. %\end{enumerate} % %\subsection{Accessing file information} @@ -595,17 +601,29 @@ Organization for Standardization} %absolute path that isn't under \texttt{\$TEXMFOUTPUT} (assuming %that environment variable hasn't been set to \file{/tmp}). % -%\subsection{MikTeX} -%Apparently MikTeX doesn't support the \texttt{openin\_any} -%variable, so if this is unset, \file{texosquery.jar} and -%\file{texosquery-jre5.jar} will fallback on \qt{\texttt{a}}, but -%the stricter \file{texosquery-jre8.jar} will fallback on -%\qt{\texttt{p}}. +%\subsection{MiKTeX}\label{sec:miktex} +%MiKTeX doesn't support the \texttt{openin\_any} +%variable so, if this is unset, \file{texosquery} will fallback on +%\qt{\texttt{a}}. % %Note that MiKTeX disables piped input by default for security %reasons. Since \cs{TeXOSQuery} relies on piped input, you'll need %to enable it with \texttt{-{}-enable-pipes} when you run \TeX. % +%\subsection{Restricted Mode}\label{sec:restricted} +%TeX Live 2017 now has \app{texosquery-jre8} on the list of trusted +%applications that may be run in restricted mode. In order to make +%use of this, you need to set up your +%\hyperref[itm:cfg]{configuration file} to use both +%\app{texosquery-jre8} and to automatically switch off the dry run +%mode if the restricted shell escape is detected. However, note that +%the restricted mode has limitations on the characters allowed in +%the shell escape for security reasons. This means that arguments +%(such as file names) can't be quoted in restricted mode and +%therefore arguments that contain spaces can't be delimited and will +%cause problems. Either avoid spaces in file names or use the +%unrestricted mode. +% %\subsection{Return Values} %\label{sec:returnvalues} %The return values may include literal text where special characters @@ -649,8 +667,7 @@ Organization for Standardization} % %You can change the default encoding by invoking the Java Virtual %Machine with the option \texttt{-Dfile.encoding=}\meta{codeset}. -%For example, bash users can modify the \file{texosquery} (or -%\file{texosquery.sh}) script to set the encoding to \gls*{UTF}-8 as follows: +%For example, bash users can modify the \file{texosquery} script to set the encoding to \gls*{UTF}-8 as follows: %\begin{verbatim} %#!/bin/sh % @@ -691,7 +708,7 @@ Organization for Standardization} %locale provider are required for that language. The proposed %Java~9 should have the CLDR enabled by default. % -%The bash script \file{texosquery-jre8} (or \file{texosquery-jre8.sh}) +%The bash script \file{texosquery-jre8} %automatically sets \texttt{java.locale.providers} to \texttt{CLDR,JRE}. %Alternatively, the \texttt{JAVA\_TOOL\_OPTIONS} environment variable %can be set to @@ -735,7 +752,8 @@ Organization for Standardization} %\end{definition} %Similarly for \app{texosquery-jre5}. (Bash users may need the %\file{.sh} extension if it wasn't removed from the script name -%during the \hyperref[sec:setup]{installation setup}.) Available actions are +%during the \hyperref[sec:setup]{installation setup}, but it's best +%to remove it.) Available actions are %described below. At least one action is required. % %Available options (must come before actions): @@ -1006,7 +1024,7 @@ Organization for Standardization} %As from v1.2, new restrictions have been placed on the value of \meta{dir} %for security reasons. For all three applications, %\app{texosquery-jre8}, \app{texosquery} and \app{texosquery-jre5}, -%the \texttt{openin\_any} setting is checked. If read access to +%the \hyperref[sec:fileaccess]{\texttt{openin\_any} setting} is checked. If read access to %\meta{dir} is forbidden by the \texttt{openin\_any} setting, then %this action returns an empty string. \emph{Additionally}, %regardless of \texttt{openin\_any}, the more restrictive @@ -1022,7 +1040,7 @@ Organization for Standardization} %of the entire filing system, which would hog resources, or that %might try to discover files outside the current working directory. An %exception is made for \app{texosquery-jre5} since that application -%is already considered insecure (due to Java 5 and 6 being +%is already considered insecure (due to Java 5 and 6 being long %deprecated), so if you really need \meta{dir} as, say \texttt{..} (the %parent directory) or \texttt{/} (the root directory), you can use %\app{texosquery-jre5} (by redefining \cs{TeXOSInvokerName} before @@ -1459,7 +1477,7 @@ Organization for Standardization} %Note that there's a difference between using the \gls{CLDR} locale data %and the JRE data. If I'm using the Java~7 compatible %\app{texosquery.jar} which only uses JRE locale data, then I get -%the above results, but if I use \file{texosquery-jre8.sh} which +%the above results, but if I use the bash script \file{texosquery-jre8} which %sets \texttt{java.locale.providers} to \texttt{CLDR,JRE} then I get %a slightly different result. The \meta{long date} is %\begin{verbatim} @@ -1531,7 +1549,7 @@ Organization for Standardization} %\begin{verbatim} %{15:59:41\tspc o\csq clock\tspc GMT}{15:59:41\tspc GMT}{15:59:41}{15:59} %\end{verbatim} -%with the \gls{JRE}. If I switch to \gls{CLDR} (\file{texosquery-jre8.sh}) I get: +%with the \gls{JRE}. If I switch to \gls{CLDR} (in the bash script \file{texosquery-jre8}) I get: %\begin{verbatim} %{16:00:51\tspc Greenwich\tspc Mean\tspc Time}{16:00:51\tspc GMT}{16:00:51}{16:00} %\end{verbatim} @@ -1755,9 +1773,8 @@ Organization for Standardization} % %The basic command to run \app{texosquery} and capture its output %in a control sequence is: -%\DescribeMacro\TeXOSQuery %\begin{definition} -%\cs{TeXOSQuery}\marg{cs}\marg{args} +%\ics{TeXOSQuery}\marg{cs}\marg{args} %\end{definition} %where \meta{cs} is the control sequence in which to store the %result and \meta{args} are the command line arguments to pass to @@ -1785,9 +1802,29 @@ Organization for Standardization} %where the characters \texttt{D} \text{:} \texttt{+} and %\texttt{\textquotesingle} all have category code 12 (other). % -%If the command failed, \meta{cs} will be set to empty. It's best to -%always test for success after using \cs{TeXOSQuery} (or one of the -%shortcut commands described below). For example: +%If you're not able to use \TeX's piped shell escape but you can +%run \app{texosquery} outside of \TeX, then another approach is to +%first run \app{texosquery} with the output redirected to a +%temporary file and then build your document, but instead of using +%\cs{TeXOSQuery}, use: +%\begin{definition} +%\ics{TeXOSQueryFromFile}\marg{cs}\marg{file name} +%\end{definition} +%where \meta{file name} is the name of the temporary file. For +%example, first run +%\begin{verbatim} +%texosquery -b -n > tmpresult.tex +%\end{verbatim} +%and then in the document: +%\begin{verbatim} +%\TeXOSQueryFromFile{\result}{tmpresult} +%\end{verbatim} +%Avoid spaces and other awkward characters in the file name. +% +%In the case of \cs{TeXOSQuery}, if the command failed, \meta{cs} will be set +%to empty. This will also occur with \cs{TeXOSQueryFromFile} if the +%file doesn't exist. It's best to always test for success after use. +%For example: %\begin{verbatim} %\TeXOSQuery{\result}{-b} %\ifx\result\empty @@ -1797,9 +1834,14 @@ Organization for Standardization} %\fi %\end{verbatim} % -%Failure can occur because the dry run mode was on, or it can occur +%In the case of \cs{TeXOSQuery}, failure can occur because the dry run mode +%was on, or it can occur %if the query was denied (for example, forbidden file access), -%or if there's a syntax error in the system call. As from +%or if there's a syntax error in the system call. In the case of +%\cs{TeXOSQueryFromFile}, the control sequence will be empty if the +%file doesn't exist or if the file was empty. +% +%As from %version 1.2, \app{texosquery} checks the \texttt{openin\_any} %setting, which may forbid read access. Java's security manager %or the filing system may also forbid read access. @@ -1849,7 +1891,7 @@ Organization for Standardization} %\end{verbatim} %since bash will pass this as %\begin{verbatim} -%texosquery.sh -p image +%texosquery -p image %\end{verbatim} %(The \verb|#1.png| part is treated as a comment.) Nor can you do %\begin{verbatim} @@ -1865,10 +1907,9 @@ Organization for Standardization} %\end{important} % %Dry run mode is determined by the conditional -%\DescribeMacro\ifTeXOSQueryDryRun -%\begin{verbatim} -%\ifTeXOSQueryDryRun -%\end{verbatim} +%\begin{definition} +%\ics{ifTeXOSQueryDryRun} +%\end{definition} %If true, the shell escape won't be used and the requested command %invocation will be printed in the transcript file prefixed with %\begin{verbatim} @@ -1925,12 +1966,11 @@ Organization for Standardization} %correctly. %\end{itemize} % -%\DescribeMacro\TeXOSInvokerName -%The \cs{TeXOSQuery} command uses \cs{TeXOSInvokerName} to reference the +%The \cs{TeXOSQuery} command uses \ics{TeXOSInvokerName} to reference the %application name. This defaults to \app{texosquery} but needs to be %redefined to reflect the particular system call that's required. -%For example, \texttt{texosquery.sh} (Unix-like with Java~7) or -%\texttt{texosquery-jre8} (Windows with Java~8). This redefinition +%For example, \texttt{texosquery} (Java~7) or +%\texttt{texosquery-jre8} (Java~8). This redefinition %can be done in the configuration file \file{texosquery.cfg} for a %system-wide setting. See section~\ref{sec:setup} for further %details. @@ -1938,24 +1978,30 @@ Organization for Standardization} %\begin{important} %Some of the shortcut commands listed below require extra arguments after the %relevant switch. These are automatically enclosed in single-quotes -%to protect any spaces. If the argument actually contains any single-quote +%to protect any spaces, but only with the \emph{unrestricted} shell escape. +%If the argument actually contains any single-quote %characters, make sure you use \verb|\string\'| to prevent -%interference. +%interference. The quote character is forbidden in the shell escape +%in restricted mode (see section~\ref{sec:restricted}), so the +%arguments won't be delimited in this case and the quote character +%should be avoided. % %Since a file name reference may need to be obtained from \cs{jobname}, %which sometimes includes double-quotes, the first double-quote pair %found is stripped in file name arguments. Any other double-quotes %will need to be protected in the same manner as single-quotes -%(but this shouldn't be an issue if you use a safe file naming scheme). +%(but this shouldn't be an issue if you use a safe file naming scheme) +%and again be aware of the limitations imposed by the restricted +%shell escape. +% %All paths should use a forward slash for the directory divider. %\end{important} % %\subsection{Locale} %The locale (\shortarg{l} or \longarg{locale-lcs}) information can be %obtained using: -%\DescribeMacro\TeXOSQueryLocale %\begin{definition} -%\cs{TeXOSQueryLocale}\marg{cs} +%\ics{TeXOSQueryLocale}\marg{cs} %\end{definition} %Note that this uses the lower case codeset form, which has a better %chance of matching the encoding names used by the \sty{inputenc} @@ -1971,55 +2017,48 @@ Organization for Standardization} % %The \gls{IETF} \gls{BCP}~47 language tag (\shortarg{b} or \longarg{bcp47}) %can be obtained using: -%\DescribeMacro\TeXOSQueryLangTag %\begin{definition} -%\cs{TeXOSQueryLangTag}\marg{cs} +%\ics{TeXOSQueryLangTag}\marg{cs} %\end{definition} % %The numeric separators and currency symbols (\shortarg{N} or %\longarg{numeric}) can be obtained using -%\DescribeMacro\TeXOSQueryNumeric %\begin{definition} -%\cs{TeXOSQueryNumeric}\marg{cs}\marg{locale} +%\ics{TeXOSQueryNumeric}\marg{cs}\marg{locale} %\end{definition} %The \meta{locale} should be a valid language tag or may be empty %for the system's default locale. Similarly for the command below. % %All the locale data (\shortarg{D} or \longarg{locale-data}) can be %obtained using -%\DescribeMacro\TeXOSQueryLocaleData %\begin{definition} -%\cs{TeXOSQueryLocaleData}\marg{cs}\marg{locale} +%\ics{TeXOSQueryLocaleData}\marg{cs}\marg{locale} %\end{definition} % %\subsection{Operating System Information} %The OS name (\shortarg{o} or \longarg{osname}) can %be obtained using: -%\DescribeMacro\TeXOSQueryName %\begin{definition} -%\cs{TeXOSQueryName}\marg{cs} +%\ics{TeXOSQueryName}\marg{cs} %\end{definition} % %The OS version (\shortarg{r} or \longarg{osversion}) can %be obtained using: -%\DescribeMacro\TeXOSQueryVersion %\begin{definition} -%\cs{TeXOSQueryVersion}\marg{cs} +%\ics{TeXOSQueryVersion}\marg{cs} %\end{definition} % %The OS architecture (\shortarg{a} or \longarg{osarch}) can %be obtained using: -%\DescribeMacro\TeXOSQueryArch %\begin{definition} -%\cs{TeXOSQueryArch}\marg{cs} +%\ics{TeXOSQueryArch}\marg{cs} %\end{definition} % %\subsection{Dates and Times} %The current date and time information (\shortarg{M} or %\longarg{date-time}) can be obtained using: -%\DescribeMacro\TeXOSQueryDateTime %\begin{definition} -%\cs{TeXOSQueryDateTime}\marg{cs} +%\ics{TeXOSQueryDateTime}\marg{cs} %\end{definition} %Example usage: %\begin{verbatim} @@ -2040,17 +2079,15 @@ Organization for Standardization} % %The time zone mappings (\shortarg{Z} or %\longarg{time-zones}) can be obtained using: -%\DescribeMacro\TeXOSQueryTimeZones %\begin{definition} -%\cs{TeXOSQueryTimeZones}\marg{cs}\marg{locale} +%\ics{TeXOSQueryTimeZones}\marg{cs}\marg{locale} %\end{definition} %Leave \meta{locale} empty if the default locale is required. % %The current date-time stamp in PDF format (\shortarg{n} or %\longarg{pdfnow}) can be obtained using: -%\DescribeMacro\TeXOSQueryNow %\begin{definition} -%\cs{TeXOSQueryNow}\marg{cs} +%\ics{TeXOSQueryNow}\marg{cs} %\end{definition} %This is provided for the benefit of users who don't have %\cs{pdfcreationdate} defined by their \TeX\ format (for example, @@ -2058,9 +2095,8 @@ Organization for Standardization} % %The modification date-time stamp in PDF format for a file %(\shortarg{d} or \longarg{pdfdate}) can be obtained using: -%\DescribeMacro\TeXOSQueryFileDate %\begin{definition} -%\cs{TeXOSQueryFileDate}\marg{cs}\marg{filename} +%\ics{TeXOSQueryFileDate}\marg{cs}\marg{filename} %\end{definition} %where \meta{filename} is the name of the file. %This is provided for the benefit of users who don't have @@ -2069,30 +2105,26 @@ Organization for Standardization} %\subsection{File Operations} %The current working directory (\shortarg{c} or \longarg{cwd}) can %be obtained using: -%\DescribeMacro\TeXOSQueryCwd %\begin{definition} -%\cs{TeXOSQueryCwd}\marg{cs} +%\ics{TeXOSQueryCwd}\marg{cs} %\end{definition} % %The home directory (\shortarg{m} or \longarg{userhome}) can %be obtained using: -%\DescribeMacro\TeXOSQueryHome %\begin{definition} -%\cs{TeXOSQueryHome}\marg{cs} +%\ics{TeXOSQueryHome}\marg{cs} %\end{definition} % %The temporary directory (\shortarg{t} or \longarg{tmpdir}) can %be obtained using: -%\DescribeMacro\TeXOSQueryTmpDir %\begin{definition} -%\cs{TeXOSQueryTmpDir}\marg{cs} +%\ics{TeXOSQueryTmpDir}\marg{cs} %\end{definition} % %The size in bytes of a file %(\shortarg{s} or \longarg{filesize}) can be obtained using: -%\DescribeMacro\TeXOSQueryFileSize %\begin{definition} -%\cs{TeXOSQueryFileSize}\marg{cs}\marg{filename} +%\ics{TeXOSQueryFileSize}\marg{cs}\marg{filename} %\end{definition} %where \meta{filename} is the name of the file. %This is provided for the benefit of users who don't have @@ -2100,9 +2132,8 @@ Organization for Standardization} % %The URI of a file %(\shortarg{u} or \longarg{uri}) can be obtained using: -%\DescribeMacro\TeXOSQueryFileURI %\begin{definition} -%\cs{TeXOSQueryFileURI}\marg{cs}\marg{filename} +%\ics{TeXOSQueryFileURI}\marg{cs}\marg{filename} %\end{definition} %where \meta{filename} is the name of the file. %(Any percent symbols \verb|%| contained in the URI will have @@ -2110,25 +2141,22 @@ Organization for Standardization} % %The canonical path of a file %(\shortarg{p} or \longarg{path}) can be obtained using: -%\DescribeMacro\TeXOSQueryFilePath %\begin{definition} -%\cs{TeXOSQueryFilePath}\marg{cs}\marg{filename} +%\ics{TeXOSQueryFilePath}\marg{cs}\marg{filename} %\end{definition} %where \meta{filename} is the name of the file. % %The canonical path of a file's parent %(\shortarg{e} or \longarg{dirname}) can be obtained using: -%\DescribeMacro\TeXOSQueryDirName %\begin{definition} -%\cs{TeXOSQueryDirName}\marg{cs}\marg{filename} +%\ics{TeXOSQueryDirName}\marg{cs}\marg{filename} %\end{definition} %where \meta{filename} is the name of the file. % %The list of files in a given directory %(\shortarg{i} or \longarg{list}) can be obtained using: -%\DescribeMacro\TeXOSQueryFileList %\begin{definition} -%\cs{TeXOSQueryFileList}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileList}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %where \meta{sep} is the separator and \meta{dir} is the directory name. %For example: @@ -2139,21 +2167,18 @@ Organization for Standardization} %current directory in the control sequence \cs{result}. % %To omit directories (\shortarg{ir} or \longarg{list-regular}): -%\DescribeMacro\TeXOSQueryRegularFileList %\begin{definition} -%\cs{TeXOSQueryRegularFileList}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileList}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %To omit regular files (\shortarg{id} or \longarg{list-dir}): -%\DescribeMacro\TeXOSQuerySubDirFileList %\begin{definition} -%\cs{TeXOSQuerySubDirList}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirList}\marg{cs}\marg{sep}\marg{dir} %\end{definition} % %A filtered list of files in a given directory %(\shortarg{f} or \longarg{filterlist}) can be obtained using: -%\DescribeMacro\TeXOSQueryFilterFileList %\begin{definition} -%\cs{TeXOSQueryFilterFileList}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileList}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %where \meta{regex} is a regular expression. \emph{Take care of any backslashes %in the regular expression!} @@ -2182,379 +2207,308 @@ Organization for Standardization} %the optional \meta{sort} argument. % %Order by last modified date starting with the oldest (\texttt{date-ascending}): -%\DescribeMacro\TeXOSQueryFileListDateAsc %\begin{definition} -%\cs{TeXOSQueryFileListDateAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListDateAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListDateAsc %\begin{definition} -%\cs{TeXOSQueryRegularFileListDateAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListDateAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListDateAsc %\begin{definition} -%\cs{TeXOSQuerySubDirListDateAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListDateAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListDateAsc %\begin{definition} -%\cs{TeXOSQueryFilterFileListDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or for the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListDateAsc %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or for the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListDateAsc %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %Order by last modified date starting with the newest (\texttt{date-descending}): -%\DescribeMacro\TeXOSQueryFileListDateDes %\begin{definition} -%\cs{TeXOSQueryFileListDateDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListDateDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListDateDes %\begin{definition} -%\cs{TeXOSQueryRegularFileListDateDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListDateDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListDateDes %\begin{definition} -%\cs{TeXOSQuerySubDirListDateDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListDateDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListDateDes %\begin{definition} -%\cs{TeXOSQueryFilterFileListDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListDateDes %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListDateDes %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %Order by file size starting with the smallest (\texttt{size-ascending}): -%\DescribeMacro\TeXOSQueryFileListSizeAsc %\begin{definition} -%\cs{TeXOSQueryFileListSizeAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListSizeAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListSizeAsc %\begin{definition} -%\cs{TeXOSQueryRegularFileListSizeAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListSizeAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListSizeAsc %\begin{definition} -%\cs{TeXOSQuerySubDirListSizeAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListSizeAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListSizeAsc %\begin{definition} -%\cs{TeXOSQueryFilterFileListSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListSizeAsc %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListSizeAsc %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %Order by file size starting with the largest (\texttt{size-descending}): -%\DescribeMacro\TeXOSQueryFileListSizeDes %\begin{definition} -%\cs{TeXOSQueryFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListSizeDes %\begin{definition} -%\cs{TeXOSQueryRegularFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListSizeDes %\begin{definition} -%\cs{TeXOSQuerySubDirListSizeDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListSizeDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListSizeDes %\begin{definition} -%\cs{TeXOSQueryFilterFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFilterFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListSizeDes %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListSizeDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListSizeDes %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListSizeDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListSizeDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} % %Order by file name in alphabetical order (\texttt{name-ascending}): -%\DescribeMacro\TeXOSQueryFileListNameAsc %\begin{definition} -%\cs{TeXOSQueryFileListNameAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListNameAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListNameAsc %\begin{definition} -%\cs{TeXOSQueryRegularFileListNameAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListNameAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListNameAsc %\begin{definition} -%\cs{TeXOSQuerySubDirListNameAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListNameAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListNameAsc %\begin{definition} -%\cs{TeXOSQueryFilterFileListNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListNameAsc %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListNameAsc %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %Order by file name in reverse alphabetical order (\texttt{name-descending}): -%\DescribeMacro\TeXOSQueryFileListNameDes %\begin{definition} -%\cs{TeXOSQueryFileListNameDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListNameDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListNameDes %\begin{definition} -%\cs{TeXOSQueryRegularFileListNameDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListNameDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListNameDes %\begin{definition} -%\cs{TeXOSQuerySubDirListNameDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListNameDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListNameDes %\begin{definition} -%\cs{TeXOSQueryFilterFileListNameDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFilterFileListNameDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListNameDes %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListNameDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListNameDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListNameDes %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListNameDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListNameDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} % %Order by file name in case-insensitive alphabetical order %(\texttt{iname-ascending}): -%\DescribeMacro\TeXOSQueryFileListNameIgnoreCaseAsc %\begin{definition} -%\cs{TeXOSQueryFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListNameIgnoreCaseAsc %\begin{definition} -%\cs{TeXOSQueryRegularFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListNameIgnoreCaseAsc %\begin{definition} -%\cs{TeXOSQuerySubDirListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListNameIgnoreCaseAsc %\begin{definition} -%\cs{TeXOSQueryFilterFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListNameIgnoreCaseAsc %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListNameIgnoreCaseAsc %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %Order by file name in reverse case-insensitive alphabetical order %(\texttt{iname-descending}): -%\DescribeMacro\TeXOSQueryFileListNameIgnoreCaseDes %\begin{definition} -%\cs{TeXOSQueryFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListNameIgnoreCaseDes %\begin{definition} -%\cs{TeXOSQueryRegularFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListNameIgnoreCaseDes %\begin{definition} -%\cs{TeXOSQuerySubDirListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListNameIgnoreCaseDes %\begin{definition} -%\cs{TeXOSQueryFilterFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListNameIgnoreCaseDes %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListNameIgnoreCaseDes %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %Order by file extension in alphabetical order (\texttt{ext-ascending}): -%\DescribeMacro\TeXOSQueryFileListExtAsc %\begin{definition} -%\cs{TeXOSQueryFileListExtAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListExtAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListExtAsc %\begin{definition} -%\cs{TeXOSQueryRegularFileListExtAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListExtAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListExtAsc %\begin{definition} -%\cs{TeXOSQuerySubDirListExtAsc}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListExtAsc}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListExtAsc %\begin{definition} -%\cs{TeXOSQueryFilterFileListExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListExtAsc %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListExtAsc %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %Order by file extension in reverse alphabetical order (\texttt{ext-descending}): -%\DescribeMacro\TeXOSQueryFileListExtDes %\begin{definition} -%\cs{TeXOSQueryFileListExtDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryFileListExtDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the regular files only list: -%\DescribeMacro\TeXOSQueryRegularFileListExtDes %\begin{definition} -%\cs{TeXOSQueryRegularFileListExtDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQueryRegularFileListExtDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or the sub-directories only list: -%\DescribeMacro\TeXOSQuerySubDirListExtDes %\begin{definition} -%\cs{TeXOSQuerySubDirListExtDes}\marg{cs}\marg{sep}\marg{dir} +%\ics{TeXOSQuerySubDirListExtDes}\marg{cs}\marg{sep}\marg{dir} %\end{definition} %or for the filtered list: -%\DescribeMacro\TeXOSQueryFilterFileListExtDes %\begin{definition} -%\cs{TeXOSQueryFilterFileListExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterFileListExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered regular files only list: -%\DescribeMacro\TeXOSQueryFilterRegularFileListExtDes %\begin{definition} -%\cs{TeXOSQueryFilterRegularFileListExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterRegularFileListExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or the filtered sub-directories only list: -%\DescribeMacro\TeXOSQueryFilterSubDirListExtDes %\begin{definition} -%\cs{TeXOSQueryFilterSubDirListExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryFilterSubDirListExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %A recursive filtered list of regular files starting from a given directory %on the current working path %(\shortarg{w} or \longarg{alk}) can be obtained using: -%\DescribeMacro\TeXOSQueryWalk %\begin{definition} -%\cs{TeXOSQueryWalk}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalk}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %where \meta{regex} is as for the filtered listings described above. % %To sort according to last modified date: -%\DescribeMacro\TeXOSQueryWalkDateAsc %\begin{definition} -%\cs{TeXOSQueryWalkDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkDateAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or in reverse order: -%\DescribeMacro\TeXOSQueryWalkDateDes %\begin{definition} -%\cs{TeXOSQueryWalkDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkDateDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %To sort according to file size: -%\DescribeMacro\TeXOSQueryWalkSizeAsc %\begin{definition} -%\cs{TeXOSQueryWalkSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkSizeAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or in reverse order: -%\DescribeMacro\TeXOSQueryWalkSizeDes %\begin{definition} -%\cs{TeXOSQueryWalkSizeDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkSizeDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %To sort according to path name (case-sensitive): -%\DescribeMacro\TeXOSQueryWalkNameAsc %\begin{definition} -%\cs{TeXOSQueryWalkNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkNameAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or in reverse order: -%\DescribeMacro\TeXOSQueryWalkNameDes %\begin{definition} -%\cs{TeXOSQueryWalkNameDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkNameDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %To sort according to path name (case-insensitive): -%\DescribeMacro\TeXOSQueryWalkNameIgnoreCaseAsc %\begin{definition} -%\cs{TeXOSQueryWalkNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkNameIgnoreCaseAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or in reverse order: -%\DescribeMacro\TeXOSQueryWalkNameIgnoreCaseDes %\begin{definition} -%\cs{TeXOSQueryWalkNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkNameIgnoreCaseDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %To sort according to file extension: -%\DescribeMacro\TeXOSQueryWalkExtAsc %\begin{definition} -%\cs{TeXOSQueryWalkExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkExtAsc}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} %or in reverse order: -%\DescribeMacro\TeXOSQueryWalkExtDes %\begin{definition} -%\cs{TeXOSQueryWalkExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} +%\ics{TeXOSQueryWalkExtDes}\marg{cs}\marg{sep}\marg{regex}\marg{dir} %\end{definition} % %\setcounter{secnumdepth}{3} @@ -2593,7 +2547,7 @@ Organization for Standardization} % \end{macrocode} % Version info. % \begin{macrocode} -\expandafter\def\csname ver@texosquery.tex\endcsname{2017/03/31 v1.3 (NLCT)} +\expandafter\def\csname ver@texosquery.tex\endcsname{2017/05/05 v1.4 (NLCT)} % \end{macrocode} % %\begin{macro}{\@texosquery@warn} @@ -2624,6 +2578,25 @@ Organization for Standardization} % \end{macrocode} %\end{macro} % +%\begin{macro}{\@texosquery@info} +%\changes{1.4}{??}{new} +% \begin{macrocode} +\ifx\PackageInfo\undefined + \def\@texosquery@info#1{% + {% + \newlinechar=`\^^J + \def\MessageBreak{^^J}% + \message{^^Jtexosquery Info: #1^^J}% + }% + } +\else + \def\@texosquery@info#1{% + \PackageInfo{texosquery}{#1}% + } +\fi +% \end{macrocode} +%\end{macro} +% %\begin{macro}{\@texosquery@err} %\changes{1.2}{2017-03-23}{new} % \begin{macrocode} @@ -2676,18 +2649,27 @@ Organization for Standardization} % \end{macrocode} %\end{macro} % -%\begin{macro}{\TeXOSQueryInvoker} +%\begin{macro}{\texosquery@input} +%\changes{1.4}{2017-05-05}{new} %If we're using \LaTeX, we'll need to use \cs{@@input} rather %than \cs{input}. % \begin{macrocode} \ifx\@@input\undefined - \def\TeXOSQueryInvoker#1{\input|"\TeXOSInvokerName\space#1" } + \let\texosquery@input\input \else - \def\TeXOSQueryInvoker#1{\@@input|"\TeXOSInvokerName\space#1" } + \let\texosquery@input\@@input \fi % \end{macrocode} %\end{macro} % +%\begin{macro}{\TeXOSQueryInvoker} +%Invoke the application in the piped shell escape with the given +%arguments. +% \begin{macrocode} +\def\TeXOSQueryInvoker#1{\texosquery@input|"\TeXOSInvokerName\space#1" } +% \end{macrocode} +%\end{macro} +% %\begin{macro}{\ifTeXOSQueryDryRun} %Provide a dry-run mode. %\changes{1.1}{2016-07-14}{dry run mode only false by default if @@ -2728,14 +2710,41 @@ Organization for Standardization} % \end{macrocode} %\end{macro} % +%\begin{macro}{\TeXOSInvokerRestrictedMessage} +%\changes{1.4}{2017-05-05}{new} +%Message used if \TeX\ is run in restricted mode but the invoker +%name hasn't been allowed. This may be redefined in the +%configuration file to customise the message if the invoker name +%isn't allowed. Set to empty or \cs{relax} if the message should be +%omitted. +% \begin{macrocode} +\def\TeXOSInvokerRestrictedMessage{% + \string\TeXOSQuery\space doesn't work in dry run mode. + \MessageBreak + If `\TeXOSInvokerName' has been added to the \MessageBreak + restricted list, make sure that + \MessageBreak \string\TeXOSQueryAllowRestricted\space + \MessageBreak has been uncommented in the configuration file + \MessageBreak (texosquery.cfg) otherwise you need to use the + \MessageBreak unrestricted shell escape} +% \end{macrocode} +%\end{macro} +%Only need to write this information to the transcript if +%\cs{TeXOSQuery} is actually used and the dry run mode is on in +%restricted mode. +%\begin{macro}{\@texosquery@dorestrictedmessage} +% \begin{macrocode} +\let\@texosquery@dorestrictedmessage\relax +% \end{macrocode} +%\end{macro} +% %Load the configuration file if it exists. %\changes{1.2}{2017-03-23}{added texosquery.cfg} % \begin{macrocode} \openin0=texosquery.cfg \ifeof0\relax \else \closein0\relax \begingroup - \newlinechar=`\^^J - \message{^^JTeXOSQuery: reading configuration file^^J}% + \@texosquery@info{reading configuration file}% \endgroup \input texosquery.cfg \fi @@ -2752,36 +2761,217 @@ Organization for Standardization} } % \end{macrocode} % -%If shell escape is unrestricted, automatically switch off dry-run -%mode, unless the cfg file has allowed it. +%\begin{macro}{\texosquery@shellescape} +%\changes{1.4}{2017-05-05}{new} +%We need to know the shell escape mode. This is provided by +%PDF\TeX's \cs{pdfshellescape} primitive or \XeTeX's +%\cs{shellescape} primitive. It's a little more complicated in +%Lua\TeX. Initialise to 0: +% \begin{macrocode} +\chardef\texosquery@shellescape=0 +% \end{macrocode} +% Test for the PDF\TeX\ and \XeTeX\ primitives. % \begin{macrocode} \ifx\shellescape\undefined \ifx\pdfshellescape\undefined - \else - \ifnum\pdfshellescape=1\relax - \TeXOSQueryDryRunfalse +% \end{macrocode} +%Neither primitive defined. Has \sty{pdftexcmds} been loaded? If so, +%we can use \cs{pdf@shellescape}. +% \begin{macrocode} + \ifx\pdf@shellescape\undefined +% \end{macrocode} +%\cs{pdf@shellescape} hasn't been defined. Is Lua\TeX\ in use? +% \begin{macrocode} + \ifx\directlua\undefined +% \end{macrocode} +%Not Lua\TeX. Most likely an old \TeX\ format. Have to assume the +%shell escape is unavailable. +% \begin{macrocode} + \else +% \end{macrocode} +%Use Lua to find the shell escape. This uses the same method as +%\sty{pdftexcmds}. (Not loading that package, as this is the only +%thing required from it.) +% \begin{macrocode} + \edef\texosquery@shellescape{\directlua0{ + if os.execute then + if status + and status.luatex_version + and status.luatex_version >= 68 then + tex.write(os.execute()) + else + local result = os.execute() + if result == 0 then + tex.write("0") + else + if result == nil then + tex.write("0") + else + tex.write("1") + end + end + end + else + tex.write("0") + end + }} + \fi \else - \@texosquery@allowrestricted - {% - \ifnum\pdfshellescape=2\relax - \TeXOSQueryDryRunfalse + \let\texosquery@shellescape\pdf@shellescape + \fi + \else +% \end{macrocode} +%PDF\TeX's \cs{pdfshellescape} has been defined, so that can be +%used, but first check it hasn't been set to \cs{relax}. +% \begin{macrocode} + \ifx\pdfshellescape\relax +% \end{macrocode} +%Something's meddled with \cs{pdfshellescape}, so try +%\cs{pdf@shellescape}. +% \begin{macrocode} + \ifx\pdf@shellescape\undefined +% \end{macrocode} +%\cs{pdf@shellescape} hasn't been defined. Is Lua\TeX\ in use? +% \begin{macrocode} + \ifx\directlua\undefined +% \end{macrocode} +%Not Lua\TeX. Most likely an old \TeX\ format. Have to assume the +%shell escape is unavailable. +% \begin{macrocode} + \else +% \end{macrocode} +%Use Lua to find the shell escape. +% \begin{macrocode} + \edef\texosquery@shellescape{\directlua0{ + if os.execute then + if status + and status.luatex_version + and status.luatex_version >= 68 then + tex.write(os.execute()) + else + local result = os.execute() + if result == 0 then + tex.write("0") + else + if result == nil then + tex.write("0") + else + tex.write("1") + end + end + end + else + tex.write("0") + end + }} \fi - } - {} + \else + \let\texosquery@shellescape\pdf@shellescape + \fi + \else + \let\texosquery@shellescape\pdfshellescape \fi \fi \else - \ifnum\shellescape=1\relax - \TeXOSQueryDryRunfalse +% \end{macrocode} +%\XeTeX's \cs{shellescape} has been defined, so that can be used, +%but first check it hasn't been set to \cs{relax}. +% \begin{macrocode} + \ifx\shellescape\relax +% \end{macrocode} +%Something's meddled with \cs{shellescape}, so try +%\cs{pdfshellescape}. +% \begin{macrocode} + \ifx\pdfshellescape\undefined + \else +% \end{macrocode} +%\cs{pdfshellescape} has been defined, so that can be used, but +%first check it hasn't been set to \cs{relax}. +% \begin{macrocode} + \ifx\pdfshellescape\relax +% \end{macrocode} +%Something's meddled with \cs{pdfshellescape}, so try +%\cs{pdf@shellescape}. +% \begin{macrocode} + \ifx\pdf@shellescape\undefined +% \end{macrocode} +%Try Lua. +% \begin{macrocode} + \ifx\directlua\undefined +% \end{macrocode} +%Not Lua\TeX. Most likely an old \TeX\ format. Have to assume the +%shell escape is unavailable. +% \begin{macrocode} + \else +% \end{macrocode} +%Use Lua to find the shell escape. +% \begin{macrocode} + \edef\texosquery@shellescape{\directlua0{ + if os.execute then + if status + and status.luatex_version + and status.luatex_version >= 68 then + tex.write(os.execute()) + else + local result = os.execute() + if result == 0 then + tex.write("0") + else + if result == nil then + tex.write("0") + else + tex.write("1") + end + end + end + else + tex.write("0") + end + }} + \fi + \else + \let\texosquery@shellescape\pdf@shellescape + \fi + \else + \let\texosquery@shellescape\pdfshellescape + \fi + \fi \else - \@texosquery@allowrestricted - {% - \ifnum\shellescape=2\relax - \TeXOSQueryDryRunfalse + \let\texosquery@shellescape\shellescape + \fi +\fi +% \end{macrocode} +%\end{macro} +% +%If shell escape is unrestricted, automatically switch off dry-run +%mode, unless the cfg file has allowed it. +% \begin{macrocode} +\ifcase\texosquery@shellescape + \@texosquery@info{shell escape disabled, dry-run mode on} +\or + \TeXOSQueryDryRunfalse +\or + \@texosquery@allowrestricted + {% + \TeXOSQueryDryRunfalse + } + {% + \@texosquery@info{shell escape restricted, dry-run mode on.} +% \end{macrocode} +%Enable the restricted warning message, but it only needs to be +%written once, so disable it after use. +% \begin{macrocode} + \def\@texosquery@dorestrictedmessage{% + \ifx\TeXOSInvokerRestrictedMessage\empty + \else + \ifx\TeXOSInvokerRestrictedMessage\relax + \else + \@texosquery@warn{\TeXOSInvokerRestrictedMessage}% + \fi \fi + \let\@texosquery@dorestrictedmessage\relax } - {} - \fi + } \fi % \end{macrocode} % @@ -3588,6 +3778,7 @@ Organization for Standardization} % \begin{macrocode} \def\TeXOSQuery#1#2{% \ifTeXOSQueryDryRun + \@texosquery@dorestrictedmessage \begingroup \newlinechar=`\^^J \message{^^JTeXOSQuery: \TeXOSInvokerName\space#2^^J}% @@ -3627,6 +3818,47 @@ Organization for Standardization} % \end{macrocode} %\end{macro} % +%\begin{macro}{\TeXOSQueryFromFile} +%\changes{1.4}{2017-05-05}{new} +%This is like \cs{TeXOSQuery} but doesn't use the piped shell +%escape. Instead, it's for cases where \app{texosquery} is run +%before \TeX\ and the results have been captured in a file. For +%example, \verb|texosquery -b > texosqueryresult.tex| +%The second argument is the file name. +% \begin{macrocode} +\def\TeXOSQueryFromFile#1#2{% +% \end{macrocode} +%First check that the file exists. +% \begin{macrocode} + \openin0=#2 + \ifeof0\relax + \def#1{}% + \else + \closein0\relax + \begingroup + \endlinechar=-1\relax + \@texosquery@enableshortcs + \catcode`\-=12\relax + \catcode`\_=12\relax + \catcode`\^=12\relax + \catcode`\~=12\relax + \catcode`\$=12\relax + \catcode`\&=12\relax + \catcode`\.=12\relax + \catcode`\/=12\relax + \catcode`\:=12\relax + \catcode`\"=12\relax + \catcode`\'=12\relax + \catcode`\;=12\relax + \catcode`\%=12\relax + \everyeof{\noexpand}\relax + \@texosquery@edef\x{\endgroup\def\noexpand#1{\texosquery@input #2 }}\x + \fi +} +% \end{macrocode} +%\end{macro} +% +% %\subsubsection{Currency} %The \meta{\TeX\ currency} element of \longarg{numeric} and %\longarg{locale-data} identifies the currency symbol using @@ -4123,6 +4355,18 @@ Organization for Standardization} } % \end{macrocode} %\end{macro} +%The restricted mode doesn't permit quotes in the shell escape, so +%arguments are only quoted in unrestricted mode. +%\begin{macro}{\@texosquery@argquote} +%\changes{1.4}{2017-05-05}{new} +% \begin{macrocode} +\ifnum\texosquery@shellescape=2\relax + \def\@texosquery@argquote#1{#1} +\else + \def\@texosquery@argquote#1{\string'#1\string'} +\fi +% \end{macrocode} +%\end{macro} % %\begin{macro}{\TeXOSQueryFileDate} %\changes{1.1}{2016-07-14}{changed catcode of D to 12} @@ -4137,7 +4381,8 @@ Organization for Standardization} \edef\@texosquery@restore@D{% \noexpand\catcode`\noexpand\D=\the\catcode`\D\relax}% \catcode`\D=12\relax - \TeXOSQuery{#1}{\string-d \string'\texosquerystripquotes{#2}\string'}% + \TeXOSQuery{#1}{\string-d + \@texosquery@argquote{\texosquerystripquotes{#2}}}% \@texosquery@restore@D } % \end{macrocode} @@ -4147,7 +4392,7 @@ Organization for Standardization} %Query the size of the file given in the second argument. % \begin{macrocode} \def\TeXOSQueryFileSize#1#2{\TeXOSQuery{#1}{\string-s - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} % \end{macrocode} %\end{macro} % @@ -4155,8 +4400,8 @@ Organization for Standardization} %\changes{1.2}{2017-03-23}{new} % \begin{macrocode} \def\@texosquery@filelist#1#2#3#4#5{\TeXOSQuery{#1}{% - \string#2 \string'#3\string' - \string'\texosquerystripquotes{#4}\string' #5}} + \string#2 \@texosquery@argquote{#3} + \@texosquery@argquote{\texosquerystripquotes{#4}} #5}} % \end{macrocode} %\end{macro} % @@ -4495,8 +4740,10 @@ Organization for Standardization} \def\@texosquery@filterfilelist#1#2#3#4#5#6{% \TeXOSQuery{#1}% {% - \string#2 \string'#3\string' \string'#4\string' - \string'\texosquerystripquotes{#5}\string' #6% + \string#2 + \@texosquery@argquote{#3} + \@texosquery@argquote{#4} + \@texosquery@argquote{\texosquerystripquotes{#5}} #6% }% } % \end{macrocode} @@ -4843,8 +5090,10 @@ Organization for Standardization} \def\@texosquery@walk#1#2#3#4#5{% \TeXOSQuery{#1}% {% - \string-w \string'#2\string' \string'#3\string' - \string'\texosquerystripquotes{#4}\string' #5% + \string-w + \@texosquery@argquote{#2} + \@texosquery@argquote{#3} + \@texosquery@argquote{\texosquerystripquotes{#4}} #5% }% } % \end{macrocode} @@ -4964,7 +5213,7 @@ Organization for Standardization} %Get the URI of the file given in the second argument. % \begin{macrocode} \def\TeXOSQueryFileURI#1#2{\TeXOSQuery{#1}{\string-u - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} % \end{macrocode} %\end{macro} % @@ -4972,7 +5221,7 @@ Organization for Standardization} %Get the canonical path of the file given in the second argument. % \begin{macrocode} \def\TeXOSQueryFilePath#1#2{\TeXOSQuery{#1}{\string-p - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} % \end{macrocode} %\end{macro} % @@ -4982,7 +5231,7 @@ Organization for Standardization} %in the second argument. % \begin{macrocode} \def\TeXOSQueryDirName#1#2{\TeXOSQuery{#1}{\string-e - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} % \end{macrocode} %\end{macro} % @@ -7008,10 +7257,10 @@ Organization for Standardization} \or \edef\@texosquery@frac{\@texosquery@int\@texosquery@frac}% \edef\@texosquery@int{0}% -% \end{macrocode} +% \end{macrocode} %Anything beyond this will require scientific notation. Hopefully the %pattern supports it. -% \begin{macrocode} +% \begin{macrocode} \fi } % \end{macrocode} @@ -7576,7 +7825,7 @@ Organization for Standardization} %Identify package: % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{texosquery}[2017/03/31 v1.3 (NLCT)] +\ProvidesPackage{texosquery}[2017/05/05 v1.4 (NLCT)] % \end{macrocode} %Load \file{texosquery.tex}: % \begin{macrocode} @@ -7597,21 +7846,37 @@ Organization for Standardization} % \end{macrocode} %\fi % \begin{macrocode} - %If this configuration file is added to TeX's path, it can - %be used to set up the texosquery defaults for the installation. + % This configuration file must be edited to match your system. + % Copy the file to your TEXMFLOCAL or TEXMFHOME tree to prevent it + % from being overwritten by updates. - %Default application (must be installed on the operating system's - %path). Change as appropriate. Available options: - % * texosquery-jre8 (at least Java 8 required) - % * texosquery (at least Java 7 required) - % * texosquery-jre5 (at least Java 5 required) - %(bash users need to check that the .sh extension has been removed - %from the bash scripts, or add the extension to the invoker name.) -\def\TeXOSInvokerName{texosquery} + % 1. Check your version of Java. To do this run + % java -version + % from your command line. + + % * If the version number starts with "1.5" or "1.6" then + % \TeXOSInvokerName must be texosquery-jre5 + % + % * If the version number starts with "1.7" then + % \TeXOSInvokerName must be texosquery + % + % * If the version number starts with "1.8" then + % \TeXOSInvokerName must be texosquery-jre8 + + % (bash users need to check that the .sh extension has been removed + % from the bash scripts.) + + \def\TeXOSInvokerName{texosquery} + + % 2. If the invoker name given in the definition above is on the + % restricted list, uncomment the line below to allow it to be run + % in restricted mode: - % If the invoker name given above is on the restricted list, - % allow it to be run in restricted mode: %\TeXOSQueryAllowRestricted + + % Leave it commented out if the invoker name is not on the + % restricted list. + % \end{macrocode} %\iffalse % \begin{macrocode} diff --git a/Master/texmf-dist/source/support/texosquery/texosquery.ins b/Master/texmf-dist/source/support/texosquery/texosquery.ins index a5fe73878e8..47c6a92102b 100644 --- a/Master/texmf-dist/source/support/texosquery/texosquery.ins +++ b/Master/texmf-dist/source/support/texosquery/texosquery.ins @@ -24,6 +24,11 @@ the corresponding batch files. \endpreamble +\declarepreamble\cfgpreamble + +Please follow the instructions below. +\endpreamble + %The following is to prevent a blank line from appearing %at the start of the bash scripts (which occurs when simply using %\nopreamble). @@ -53,9 +58,9 @@ } \file{texosquery.cfg}% {% - \usepreamble\defaultpreamble + \usepreamble\cfgpreamble \usepostamble\defaultpostamble - \from{texosquery.dtx}{texosquery.cfg,package}% + \from{texosquery.dtx}{texosquery.cfg}% } \file{texosquery.sh}% {% diff --git a/Master/texmf-dist/tex/latex/texosquery/texosquery.cfg b/Master/texmf-dist/tex/latex/texosquery/texosquery.cfg index 9422e0c7feb..ff7994c6bb4 100644 --- a/Master/texmf-dist/tex/latex/texosquery/texosquery.cfg +++ b/Master/texmf-dist/tex/latex/texosquery/texosquery.cfg @@ -4,59 +4,42 @@ %% %% The original source files were: %% -%% texosquery.dtx (with options: `texosquery.cfg,package') -%% texosquery -%% Copyright 2017 Nicola Talbot +%% texosquery.dtx (with options: `texosquery.cfg') %% -%% This work may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3 -%% of this license of (at your option) any later version. -%% The latest version of this license is in -%% http://www.latex-project.org/lppl.txt -%% and version 1.3 or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Nicola Talbot. -%% -%% This work consists of the files texosquery.dtx and texosquery.ins -%% and the derived files texosquery.sty, texosquery.tex and -%% texosquery.cfg. Additionally, the Java applications texosquery.jar, -%% texosquery-jre5.jar, texosquery-jre8.jar, the bash scripts -%% texosquery.sh, texosquery-jre5.sh, texosquery-jre8.sh, and -%% the corresponding batch files. -%% \CharacterTable -%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z -%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z -%% Digits \0\1\2\3\4\5\6\7\8\9 -%% Exclamation \! Double quote \" Hash (number) \# -%% Dollar \$ Percent \% Ampersand \& -%% Acute accent \' Left paren \( Right paren \) -%% Asterisk \* Plus \+ Comma \, -%% Minus \- Point \. Solidus \/ -%% Colon \: Semicolon \; Less than \< -%% Equals \= Greater than \> Question mark \? -%% Commercial at \@ Left bracket \[ Backslash \\ -%% Right bracket \] Circumflex \^ Underscore \_ -%% Grave accent \` Left brace \{ Vertical bar \| -%% Right brace \} Tilde \~} - - %If this configuration file is added to TeX's path, it can - %be used to set up the texosquery defaults for the installation. - - %Default application (must be installed on the operating system's - %path). Change as appropriate. Available options: - % * texosquery-jre8 (at least Java 8 required) - % * texosquery (at least Java 7 required) - % * texosquery-jre5 (at least Java 5 required) - %(bash users need to check that the .sh extension has been removed - %from the bash scripts, or add the extension to the invoker name.) -\def\TeXOSInvokerName{texosquery} - - % If the invoker name given above is on the restricted list, - % allow it to be run in restricted mode: +%% Please follow the instructions below. + + + % This configuration file must be edited to match your system. + % Copy the file to your TEXMFLOCAL or TEXMFHOME tree to prevent it + % from being overwritten by updates. + + % 1. Check your version of Java. To do this run + % java -version + % from your command line. + + % * If the version number starts with "1.5" or "1.6" then + % \TeXOSInvokerName must be texosquery-jre5 + % + % * If the version number starts with "1.7" then + % \TeXOSInvokerName must be texosquery + % + % * If the version number starts with "1.8" then + % \TeXOSInvokerName must be texosquery-jre8 + + % (bash users need to check that the .sh extension has been removed + % from the bash scripts.) + + \def\TeXOSInvokerName{texosquery} + + % 2. If the invoker name given in the definition above is on the + % restricted list, uncomment the line below to allow it to be run + % in restricted mode: + %\TeXOSQueryAllowRestricted + + % Leave it commented out if the invoker name is not on the + % restricted list. + \endinput %% %% End of file `texosquery.cfg'. diff --git a/Master/texmf-dist/tex/latex/texosquery/texosquery.sty b/Master/texmf-dist/tex/latex/texosquery/texosquery.sty index 7f7174f48ae..ae334b31c46 100644 --- a/Master/texmf-dist/tex/latex/texosquery/texosquery.sty +++ b/Master/texmf-dist/tex/latex/texosquery/texosquery.sty @@ -42,8 +42,9 @@ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} + \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{texosquery}[2017/03/31 v1.3 (NLCT)] +\ProvidesPackage{texosquery}[2017/05/05 v1.4 (NLCT)] \input{texosquery} \endinput %% diff --git a/Master/texmf-dist/tex/latex/texosquery/texosquery.tex b/Master/texmf-dist/tex/latex/texosquery/texosquery.tex index d004f4503c2..85bfe6470b2 100644 --- a/Master/texmf-dist/tex/latex/texosquery/texosquery.tex +++ b/Master/texmf-dist/tex/latex/texosquery/texosquery.tex @@ -42,6 +42,7 @@ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} + \ifnum\catcode`\@=11\relax \def\@texosquery@restore@at{}% \else @@ -54,7 +55,7 @@ \@texosquery@restore@at \expandafter\endinput \fi -\expandafter\def\csname ver@texosquery.tex\endcsname{2017/03/31 v1.3 (NLCT)} +\expandafter\def\csname ver@texosquery.tex\endcsname{2017/05/05 v1.4 (NLCT)} \ifx\@tracklang@pkgwarn\undefined \ifx\PackageWarning\undefined \def\@texosquery@warn#1{% @@ -74,6 +75,19 @@ \@tracklang@pkgwarn{texosquery}{#1}% } \fi +\ifx\PackageInfo\undefined + \def\@texosquery@info#1{% + {% + \newlinechar=`\^^J + \def\MessageBreak{^^J}% + \message{^^Jtexosquery Info: #1^^J}% + }% + } +\else + \def\@texosquery@info#1{% + \PackageInfo{texosquery}{#1}% + } +\fi \ifx\PackageError\undefined \def\@texosquery@err#1#2{% \errhelp{#2}% @@ -107,10 +121,11 @@ \fi \def\TeXOSInvokerName{texosquery} \ifx\@@input\undefined - \def\TeXOSQueryInvoker#1{\input|"\TeXOSInvokerName\space#1" } + \let\texosquery@input\input \else - \def\TeXOSQueryInvoker#1{\@@input|"\TeXOSInvokerName\space#1" } + \let\texosquery@input\@@input \fi +\def\TeXOSQueryInvoker#1{\texosquery@input|"\TeXOSInvokerName\space#1" } \newif\ifTeXOSQueryDryRun \TeXOSQueryDryRuntrue \def\TeXOSQueryAllowRestricted{% \def\@texosquery@allowrestricted##1##2{##1}% @@ -119,11 +134,20 @@ \def\@texosquery@allowrestricted##1##2{##2}% } \def\@texosquery@allowrestricted#1#2{#2}% +\def\TeXOSInvokerRestrictedMessage{% + \string\TeXOSQuery\space doesn't work in dry run mode. + \MessageBreak + If `\TeXOSInvokerName' has been added to the \MessageBreak + restricted list, make sure that + \MessageBreak \string\TeXOSQueryAllowRestricted\space + \MessageBreak has been uncommented in the configuration file + \MessageBreak (texosquery.cfg) otherwise you need to use the + \MessageBreak unrestricted shell escape} +\let\@texosquery@dorestrictedmessage\relax \openin0=texosquery.cfg \ifeof0\relax \else \closein0\relax \begingroup - \newlinechar=`\^^J - \message{^^JTeXOSQuery: reading configuration file^^J}% + \@texosquery@info{reading configuration file}% \endgroup \input texosquery.cfg \fi @@ -135,33 +159,137 @@ \@texosquery@warn{\string\TeXOSQueryDenyRestricted\space ignored (only allowed in texosquery.cfg)}% } +\chardef\texosquery@shellescape=0 \ifx\shellescape\undefined \ifx\pdfshellescape\undefined - \else - \ifnum\pdfshellescape=1\relax - \TeXOSQueryDryRunfalse + \ifx\pdf@shellescape\undefined + \ifx\directlua\undefined + \else + \edef\texosquery@shellescape{\directlua0{ + if os.execute then + if status + and status.luatex_version + and status.luatex_version >= 68 then + tex.write(os.execute()) + else + local result = os.execute() + if result == 0 then + tex.write("0") + else + if result == nil then + tex.write("0") + else + tex.write("1") + end + end + end + else + tex.write("0") + end + }} + \fi \else - \@texosquery@allowrestricted - {% - \ifnum\pdfshellescape=2\relax - \TeXOSQueryDryRunfalse + \let\texosquery@shellescape\pdf@shellescape + \fi + \else + \ifx\pdfshellescape\relax + \ifx\pdf@shellescape\undefined + \ifx\directlua\undefined + \else + \edef\texosquery@shellescape{\directlua0{ + if os.execute then + if status + and status.luatex_version + and status.luatex_version >= 68 then + tex.write(os.execute()) + else + local result = os.execute() + if result == 0 then + tex.write("0") + else + if result == nil then + tex.write("0") + else + tex.write("1") + end + end + end + else + tex.write("0") + end + }} \fi - } - {} + \else + \let\texosquery@shellescape\pdf@shellescape + \fi + \else + \let\texosquery@shellescape\pdfshellescape \fi \fi \else - \ifnum\shellescape=1\relax - \TeXOSQueryDryRunfalse + \ifx\shellescape\relax + \ifx\pdfshellescape\undefined + \else + \ifx\pdfshellescape\relax + \ifx\pdf@shellescape\undefined + \ifx\directlua\undefined + \else + \edef\texosquery@shellescape{\directlua0{ + if os.execute then + if status + and status.luatex_version + and status.luatex_version >= 68 then + tex.write(os.execute()) + else + local result = os.execute() + if result == 0 then + tex.write("0") + else + if result == nil then + tex.write("0") + else + tex.write("1") + end + end + end + else + tex.write("0") + end + }} + \fi + \else + \let\texosquery@shellescape\pdf@shellescape + \fi + \else + \let\texosquery@shellescape\pdfshellescape + \fi + \fi \else - \@texosquery@allowrestricted - {% - \ifnum\shellescape=2\relax - \TeXOSQueryDryRunfalse + \let\texosquery@shellescape\shellescape + \fi +\fi +\ifcase\texosquery@shellescape + \@texosquery@info{shell escape disabled, dry-run mode on} +\or + \TeXOSQueryDryRunfalse +\or + \@texosquery@allowrestricted + {% + \TeXOSQueryDryRunfalse + } + {% + \@texosquery@info{shell escape restricted, dry-run mode on.} + \def\@texosquery@dorestrictedmessage{% + \ifx\TeXOSInvokerRestrictedMessage\empty + \else + \ifx\TeXOSInvokerRestrictedMessage\relax + \else + \@texosquery@warn{\TeXOSInvokerRestrictedMessage}% + \fi \fi + \let\@texosquery@dorestrictedmessage\relax } - {} - \fi + } \fi \ifx\@texosquery@edef\undefined \ifx\protected@edef\undefined @@ -359,6 +487,7 @@ } \def\TeXOSQuery#1#2{% \ifTeXOSQueryDryRun + \@texosquery@dorestrictedmessage \begingroup \newlinechar=`\^^J \message{^^JTeXOSQuery: \TeXOSInvokerName\space#2^^J}% @@ -385,6 +514,32 @@ \@texosquery@edef\x{\endgroup\def\noexpand#1{\TeXOSQueryInvoker{#2}}}\x \fi } +\def\TeXOSQueryFromFile#1#2{% + \openin0=#2 + \ifeof0\relax + \def#1{}% + \else + \closein0\relax + \begingroup + \endlinechar=-1\relax + \@texosquery@enableshortcs + \catcode`\-=12\relax + \catcode`\_=12\relax + \catcode`\^=12\relax + \catcode`\~=12\relax + \catcode`\$=12\relax + \catcode`\&=12\relax + \catcode`\.=12\relax + \catcode`\/=12\relax + \catcode`\:=12\relax + \catcode`\"=12\relax + \catcode`\'=12\relax + \catcode`\;=12\relax + \catcode`\%=12\relax + \everyeof{\noexpand}\relax + \@texosquery@edef\x{\endgroup\def\noexpand#1{\texosquery@input #2 }}\x + \fi +} \def\texosquerycurrency#1{% \expandafter\noexpand\csname texosquerycurrency#1\endcsname } @@ -544,18 +699,24 @@ \def\@@texosquery@stripquotes#1\@mid@texosquery@stripquotes#2\@end@texosquery@stripquotes{% #1% } +\ifnum\texosquery@shellescape=2\relax + \def\@texosquery@argquote#1{#1} +\else + \def\@texosquery@argquote#1{\string'#1\string'} +\fi \def\TeXOSQueryFileDate#1#2{% \edef\@texosquery@restore@D{% \noexpand\catcode`\noexpand\D=\the\catcode`\D\relax}% \catcode`\D=12\relax - \TeXOSQuery{#1}{\string-d \string'\texosquerystripquotes{#2}\string'}% + \TeXOSQuery{#1}{\string-d + \@texosquery@argquote{\texosquerystripquotes{#2}}}% \@texosquery@restore@D } \def\TeXOSQueryFileSize#1#2{\TeXOSQuery{#1}{\string-s - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} \def\@texosquery@filelist#1#2#3#4#5{\TeXOSQuery{#1}{% - \string#2 \string'#3\string' - \string'\texosquerystripquotes{#4}\string' #5}} + \string#2 \@texosquery@argquote{#3} + \@texosquery@argquote{\texosquerystripquotes{#4}} #5}} \def\TeXOSQueryFileList#1#2#3{% \@texosquery@filelist{#1}{-i}{#2}{#3}{}% } @@ -658,8 +819,10 @@ \def\@texosquery@filterfilelist#1#2#3#4#5#6{% \TeXOSQuery{#1}% {% - \string#2 \string'#3\string' \string'#4\string' - \string'\texosquerystripquotes{#5}\string' #6% + \string#2 + \@texosquery@argquote{#3} + \@texosquery@argquote{#4} + \@texosquery@argquote{\texosquerystripquotes{#5}} #6% }% } \def\TeXOSQueryFilterFileList#1#2#3#4{% @@ -764,8 +927,10 @@ \def\@texosquery@walk#1#2#3#4#5{% \TeXOSQuery{#1}% {% - \string-w \string'#2\string' \string'#3\string' - \string'\texosquerystripquotes{#4}\string' #5% + \string-w + \@texosquery@argquote{#2} + \@texosquery@argquote{#3} + \@texosquery@argquote{\texosquerystripquotes{#4}} #5% }% } \def\TeXOSQueryWalk#1#2#3#4{% @@ -802,11 +967,11 @@ \@texosquery@walk{#1}{#2}{#3}{#4}{ext\string-des}% } \def\TeXOSQueryFileURI#1#2{\TeXOSQuery{#1}{\string-u - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} \def\TeXOSQueryFilePath#1#2{\TeXOSQuery{#1}{\string-p - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} \def\TeXOSQueryDirName#1#2{\TeXOSQuery{#1}{\string-e - \string'\texosquerystripquotes{#2}\string'}} + \@texosquery@argquote{\texosquerystripquotes{#2}}}} \def\texosquerydtf#1#2{% \ifcase#1 \or -- cgit v1.2.3