Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Why do \message{\input|"texlua ..."} and \message{\input|"texlua ..." } give very different results? Notice the extra space before } in the second case.

Minimal example to be compiled with pdftex --shell-escape below.

% Create an empty file \jobname.lua
%
\immediate\openout5\jobname.lua
\immediate\closeout5
%
% Only difference between \A and \B: a trailing space.
% Set \everyeof to allow \input within \edef.
%
\everyeof{\noexpand}
\edef\A{\input|"texlua \jobname.lua"}
\edef\B{\input|"texlua \jobname.lua" }
%
% Display the meanings in the terminal.
%
\newlinechar=10
\message
  {%
    ^^J^^J%
    \meaning\A % => macro:->Script file <jobname>.lua
    ^^J^^J%
    \meaning\B % => macro:->\par
    ^^J^^J%
  }
\bye
share|improve this question
    
Maybe the " character is active here? Like it is when using [ngerman]{babel} for composing glyphs with a diaeresis ("aä). –  Patrick Bergner Aug 2 '12 at 10:30
    
@PatrickBergner No, it's not that as if you have for example a letter after the closing " then all is fine. I think it's to do with the fact that TeX delimits file names with a space, but can't quite work out why that gives the behaviour seen. –  Joseph Wright Aug 2 '12 at 11:24
    
hmm in an unmodified TL2012 (cygwin) I get $ luatex --shell-escape in This is LuaTeX, Version beta-0.70.2-2012062812 (TeX Live 2012) \write18 enabled. (./in.tex ! I can't find file `|texlua in.lua}'. –  David Carlisle Aug 2 '12 at 11:45
    
@DavidCarlisle This syntax is only available in pdfTeX, as for LuaTeX you are supposed to use the Lua interface. (That is true for several pdfTeX primitives. See most obviously \pdfstrcmp.) –  Joseph Wright Aug 2 '12 at 12:29
add comment

1 Answer

up vote 4 down vote accepted

I would say it is because the quotes are not argument braces, only quotes to guard e.g. spaces. If you run e.g. this:

\input "abc"d

\input "abc" d
\bye

You will get this error messages (assuming of course that the files don't exist):

! I can't find file `abcd'.
l.14 \input "abc"d

and

! I can't find file `abc'.
l.16 \input "abc" 
                  d

Also e.g. with xetex \XeTeXinputencoding "utf8"cde will lead to Unknown encoding utf8cde. You must use a space to actually end the input.

Addition after the discussion in the comments:

This means that the \edef\A case is processed probably along this lines: \edef\A{\input|"texlua \jobname.lua"}\relax => \edef\A{Script file <jobname>.lua>} not found => \A is Script file <jobname>.lua and not found is typeset.

share|improve this answer
    
I can see this argument, but shouldn't the space in Bruno's question terminate the 'filename', and leave \input with the same string to deal with. –  Joseph Wright Aug 2 '12 at 12:37
    
Which space? In the case of \B the processing order is clear: The argument of \input is ended inside the braces. But in case of A things are more complicated. E.g. {\input|"texlua \jobname.lua"}abc leads for me (with --enable-pipes to this text in the pdf: Script le test-utf8.luaabc not found. Which shows that the \input looks behind the brace. –  Ulrike Fischer Aug 2 '12 at 12:51
    
I think this only partially answers the question. If |texlua \jobname.lua} is taken as a file name, hence texlua \jobname.lua} is run in the command, how come texlua doesn't just return a "no such file" error? –  Bruno Le Floch Aug 2 '12 at 12:55
2  
Ah! I think your last comment leads to an explanation: {\input|"texlua foo.lua"}abc => texlua issues the error message Script file foo.lua}abc not found, so in TeX we have the equivalent of {Script file foo.lua}abc not found, which leads to your foo.luaabc output in the pdf, but in my case leads to putting a mysterious Script file foo.lua in \A and typesets abc not found. –  Bruno Le Floch Aug 2 '12 at 13:00
1  
@UlrikeFischer I think the rest is simply left in the input stream after the \edef ends, and is typeset. So \edef\A{\input|"texlua \jobname.lua"}\relax => \edef\A{Script file <jobname>.lua>} not found => \A is Script file and not found is typeset. Can you add something along those lines to your answer, should I, or should I add a separate answer? –  Bruno Le Floch Aug 2 '12 at 13:32
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.