Interactive behaviour

Stepan Kasal <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Organization <><
Message-ID <[email protected]>
Hello,
  current CVS version of m4 sets interactive mode iff the stdin is a
tty.  I think it would be better to set interactive mode iff the
stdin, the stdout, and the stderr are a tty.  (Something like the
patch below.)

Background: autom4te currently calls "m4 </dev/null" to ensure
non-interactive mode for both m4-1.4 and m4-2.0.
To teach autom4te to handle stdin correctly, I would like to remove
the redirection.
I mailed about that to m4-discuss, and the above proposal is a
variation of what Gary proposed there:
http://lists.gnu.org/archive/html/m4-discuss/2006-04/threads.html
(Yes, autom4te could make use of the option `-b', testing first
whether it is available, yet I would prefer the above solution.)

Wdyt about this?

Stepan Kasal


Index: src/main.c
===================================================================
RCS file: /cvsroot/m4/m4/src/main.c,v
retrieving revision 1.85
diff -u -r1.85 main.c
--- src/main.c	20 Sep 2006 04:04:29 -0000	1.85
+++ src/main.c	20 Sep 2006 11:13:54 -0000
@@ -263,7 +263,7 @@
   setup_stackovf_trap (argv, envp, stackovf_handler);
 #endif
 
-  if (isatty (STDIN_FILENO))
+  if (isatty (STDIN_FILENO) && isatty (STDOUT_FILENO) && isatty (STDERR_FILENO))
     m4_set_interactive_opt (context, true);
 
   if (getenv ("POSIXLY_CORRECT"))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.