Module Name:    src
Committed By:   christos
Date:           Thu Jan 27 23:11:41 UTC 2011

Modified Files:
        src/lib/libedit: el.c el.h tty.c

Log Message:
don't turn on editing if stdout is not a tty.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/el.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libedit/el.h
cvs rdiff -u -r1.33 -r1.34 src/lib/libedit/tty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libedit/el.c
diff -u src/lib/libedit/el.c:1.60 src/lib/libedit/el.c:1.61
--- src/lib/libedit/el.c:1.60	Sat Aug 28 11:44:59 2010
+++ src/lib/libedit/el.c	Thu Jan 27 18:11:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.c,v 1.60 2010/08/28 15:44:59 christos Exp $	*/
+/*	$NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c	8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.60 2010/08/28 15:44:59 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -72,6 +72,8 @@
 	el->el_errfile = ferr;
 
 	el->el_infd = fileno(fin);
+	el->el_outfd = fileno(fout);
+	el->el_errfd = fileno(ferr);
 
 	el->el_prog = Strdup(ct_decode_string(prog, &el->el_scratch));
 	if (el->el_prog == NULL) {
@@ -333,9 +335,11 @@
 			break;
 		case 1:
 			el->el_outfile = fp;
+			el->el_outfd = fileno(fp);
 			break;
 		case 2:
 			el->el_errfile = fp;
+			el->el_errfd = fileno(fp);
 			break;
 		default:
 			rv = -1;

Index: src/lib/libedit/el.h
diff -u src/lib/libedit/el.h:1.21 src/lib/libedit/el.h:1.22
--- src/lib/libedit/el.h:1.21	Thu Dec 31 10:58:26 2009
+++ src/lib/libedit/el.h	Thu Jan 27 18:11:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.h,v 1.21 2009/12/31 15:58:26 christos Exp $	*/
+/*	$NetBSD: el.h,v 1.22 2011/01/27 23:11:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -119,6 +119,8 @@
 	FILE		 *el_outfile;	/* Stdio stuff			*/
 	FILE		 *el_errfile;	/* Stdio stuff			*/
 	int		  el_infd;	/* Input file descriptor	*/
+	int		  el_outfd;	/* Output file descriptor	*/
+	int		  el_errfd;	/* Error file descriptor	*/
 	int		  el_flags;	/* Various flags.		*/
 	int		  el_errno;	/* Local copy of errno		*/
 	coord_t		  el_cursor;	/* Cursor location		*/

Index: src/lib/libedit/tty.c
diff -u src/lib/libedit/tty.c:1.33 src/lib/libedit/tty.c:1.34
--- src/lib/libedit/tty.c:1.33	Sun Apr 18 17:17:22 2010
+++ src/lib/libedit/tty.c	Thu Jan 27 18:11:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.33 2010/04/18 21:17:22 christos Exp $	*/
+/*	$NetBSD: tty.c,v 1.34 2011/01/27 23:11:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)tty.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: tty.c,v 1.33 2010/04/18 21:17:22 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.34 2011/01/27 23:11:40 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -46,6 +46,7 @@
  */
 #include <assert.h>
 #include <errno.h>
+#include <unistd.h>	/* for isatty */
 #include <strings.h>	/* for ffs */
 #include "el.h"
 #include "tty.h"
@@ -496,6 +497,14 @@
 	if (el->el_flags & EDIT_DISABLED)
 		return (0);
 
+	if (!isatty(el->el_outfd)) {
+#ifdef DEBUG_TTY
+		(void) fprintf(el->el_errfile,
+		    "tty_setup: isatty: %s\n", strerror(errno));
+#endif /* DEBUG_TTY */
+		return (-1);
+	}
+	&el->el_tty.t_ed) == -1) {
 	if (tty_getty(el, &el->el_tty.t_ed) == -1) {
 #ifdef DEBUG_TTY
 		(void) fprintf(el->el_errfile,

Reply via email to