On 24 February 2015 at 16:39, Eli Zaretskii <e...@gnu.org> wrote:
> Running the non-interactive Info tests revealed a problem in the
> reader: it would abort when invoked with redirected stdin/stdout,
> because the MinGW-specific terminal initialization bails out in that
> case.  A patch to fix that is attached below.


> 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?

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?
Whereabouts in the function does it abort?

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. The real initialization is done in terminal_prep_terminal
- could any of the code that breaks be moved there?

Reply via email to