> Date: Tue, 24 Feb 2015 19:56:41 +0000
> From: Gavin Smith <gavinsmith0...@gmail.com>
> Cc: Karl Berry <k...@freefriends.org>, Texinfo <bug-texinfo@gnu.org>
> 
> > Here's the patch to avoid terminal initialization in non-interactive
> > sessions.  (If you think this should be confined to the MinGW port, I
> > can move this to pcterm.c instead.)  I think using isatty here
> > requires to import a Gnulib module, since the stock Windows version of
> > isatty returns non-zero for any character device, including the null
> > device, which is undesirable.
> >
> > 2015-02-24  Eli Zaretskii  <e...@gnu.org>
> >
> >         * info/info.c (main): Don't call initialize_terminal_and_keymaps
> >         if stdout is not a terminal device.
> >
> >
> > --- info/session.c~     2015-02-21 14:04:07 +0200
> > +++ info/session.c      2015-02-24 12:49:36 +0200
> > @@ -260,7 +260,8 @@ void
> >  initialize_terminal_and_keymaps (char *init_file)
> >  {
> >    char *term_name = getenv ("TERM");
> > -  terminal_initialize_terminal (term_name);
> > +  if (isatty (fileno (stdout)))
> > +    terminal_initialize_terminal (term_name);
> >    read_init_file (init_file);
> >  }
> >
> >
> 
> isatty is already used in info.c in main to check to see if the
> retrieved node(s) should be dumped to stdout, non-interactively. Does
> it get past that check once this patch is applied, or does it still
> need to be tested with a Gnulib module?

We need to use the Gnulib replacement for isatty wherever we want to
distinguish between a console and the null device, because the MS
implementation doesn't distinguish between them.  (There are other
character devices on Windows, and they all will return non-zero from
the MS isatty, but their use is much less frequent.)

> Is it possible to change the version of terminal_initialize_terminal
> for MinGW (pc_initialize_terminal in pcterm.c, I think) not to abort -
> maybe it could set terminal_is_dumb_p so we can exit later?

Yes, I can do that if you prefer it that way.

> Whereabouts in the function does it abort?

pcterm.c:gettextinfo calls 'exit'.

> The reason that terminal_initialize_terminal is called before reading
> the init file is that it needs to initialize the strings sent by
> special keys on the keyboard for the purpose of initializing the
> keybindings.

But do we need this in a non-interactive invocation of 'info'?

> The real initialization is done in terminal_prep_terminal - could
> any of the code that breaks be moved there?

That'd require more significant changes, and is not really right for
MS-Windows.  terminal_prep_terminal can be called several times during
a session, while the initialization done in terminal_initialize_terminal
is only done once.

Reply via email to