Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit don't turn on editing if stdout is not a tty.
details: https://anonhg.NetBSD.org/src/rev/7a5add5d2c6d
branches: trunk
changeset: 761450:7a5add5d2c6d
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 27 23:11:40 2011 +0000
description:
don't turn on editing if stdout is not a tty.
diffstat:
lib/libedit/el.c | 8 ++++++--
lib/libedit/el.h | 4 +++-
lib/libedit/tty.c | 13 +++++++++++--
3 files changed, 20 insertions(+), 5 deletions(-)
diffs (98 lines):
diff -r cc515e736074 -r 7a5add5d2c6d lib/libedit/el.c
--- a/lib/libedit/el.c Thu Jan 27 21:55:25 2011 +0000
+++ b/lib/libedit/el.c Thu Jan 27 23:11:40 2011 +0000
@@ -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;
diff -r cc515e736074 -r 7a5add5d2c6d lib/libedit/el.h
--- a/lib/libedit/el.h Thu Jan 27 21:55:25 2011 +0000
+++ b/lib/libedit/el.h Thu Jan 27 23:11:40 2011 +0000
@@ -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 */
diff -r cc515e736074 -r 7a5add5d2c6d lib/libedit/tty.c
--- a/lib/libedit/tty.c Thu Jan 27 21:55:25 2011 +0000
+++ b/lib/libedit/tty.c Thu Jan 27 23:11:40 2011 +0000
@@ -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,
Home |
Main Index |
Thread Index |
Old Index