[tex-live] Bug in TexLive 2005 and 2007? Non-writable aux-file

Heiko Oberdiek oberdiek at uni-freiburg.de
Tue Mar 6 22:51:31 CET 2007


On Tue, Mar 06, 2007 at 05:48:05PM +0000, Philip & Le Khanh wrote:

> I confess I was confused by the possible involvement
> of LaTeX, particularly as the log file shewed
> "\openout1 = `ex.tex'." which did not appear
> in the original.  However, I have now replicated
> the problem using Plain TeX :
> 
> 
> > ALPHA6::Chaa006 : type ex.tex;3
> > \newwrite \aux
> > \immediate \openout \aux = ex.aux
> > \immediate \write \aux {END}
> > \immediate \closeout \aux
> >
> > \end
> > ALPHA6::Chaa006 :
> 
> and I can confirm that (under VMS), Ctrl-C followed
> by "X" has exactly the same effect as with the LaTeX
> example.  Thus it does indeed seem that it is TeX
> itself that is implicated, rather than LaTeX or Web2C.

Variant: with "././fx.aux" as output file and compatible with iniTeX:

\catcode`\{=1
\catcode`\}=2
\ifx\newwrite\UnDeFiNeD
  \chardef\aux=0
\else
  \newwrite\aux
\fi
\immediate\openout\aux=././fx.aux
\immediate\write\aux{END}
\immediate\closeout\aux
\end

Result:

TeX 3.14159 (Web2C 7.5.2) --> .tex
TeX 3.141592 (Web2C 7.5.6) --> fx.tex

Responsible is the following code of tex.ch for prompt_file_name:

  @x [29.530] l.10258 - prompt_file_name: prevent empty filenames.
  clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>;
  if cur_ext="" then cur_ext:=e;
  @y
  saved_cur_name:=cur_name;
  clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>;
  if cur_ext="" then cur_ext:=e;
  if length(cur_name)=0 then cur_name:=saved_cur_name;
  @z

If the complete file name is empty, then TeX replaces the
file name extension with ".tex" here, because prompt_file_name
is called with this default extension for openout.
  Newer versions of Web2C now adds the line before "@z" that
also replaces an empty name with the previous name.

A funny side effect: if the user omits the name part and only prompts
the extension, e.g. ".hello", then TeX opens "fx.hello" in
the example above.

The automatic replacements of name parts are quite nasty. For instance,
it is impossible to write to files without extensions.

The Web2C update makes things worse, because more complicate:

\openout=.ext
Prompt: .new
Result: .new (expected)

\openout=foobar.ext
Prompt: .new
Result: foobar.new (I don't think that is expected by the user.)

Summary:

If the user is asked for an output file name, then we already
have an error condition. If the user does not provide a
file name, then he is probably unable/unwilling to provide
the correct error recovery. Then just aborting is IMHO the best
choice than writing to more or less randomly choosen file names
with the risk of overwriting files.

Thus I vote for abortion if the prompted output file name is empty

  @y
  saved_cur_name:=cur_name;
  clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>;
  if (s="output file name") and (cur_ext="") and (length(cur_name)=0) then
    fatal_error("*** (job aborted, empty output file name)");
  if cur_ext="" then cur_ext:=e;
  {? if length(cur_name)=0 then cur_name:=saved_cur_name; ?}
  @z

I even prefer to do it for all cases:

  @y
  saved_cur_name:=cur_name;
  clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>;
  if (cur_ext="") and (length(cur_name)=0) then   
    fatal_error("*** (job aborted, empty file name");
  if cur_ext="" then cur_ext:=e;
  {? if length(cur_name)=0 then cur_name:=saved_cur_name; ?}
  @z

This would save a lot of trouble and it is a very nice way to
end the prompt loop for a file name, because CTRL-C isn't working
until a valid file name is found.

Yours sincerely
  Heiko <oberdiek at uni-freiburg.de>


More information about the tex-live mailing list