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 --- .../texmf-dist/tex/latex/texosquery/texosquery.cfg | 85 +++----- .../texmf-dist/tex/latex/texosquery/texosquery.sty | 3 +- .../texmf-dist/tex/latex/texosquery/texosquery.tex | 231 ++++++++++++++++++--- 3 files changed, 234 insertions(+), 85 deletions(-) (limited to 'Master/texmf-dist/tex/latex/texosquery') 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