Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/csh defer editing setup/cleanup to when we are interactive.
details: https://anonhg.NetBSD.org/src/rev/2abda0567efe
branches: trunk
changeset: 370064:2abda0567efe
user: christos <christos%NetBSD.org@localhost>
date: Wed Sep 14 16:15:51 2022 +0000
description:
defer editing setup/cleanup to when we are interactive.
diffstat:
bin/csh/csh.c | 6 +++-
bin/csh/extern.h | 3 +-
bin/csh/set.c | 63 +++++++++++++++++++++++++++++++++----------------------
3 files changed, 44 insertions(+), 28 deletions(-)
diffs (149 lines):
diff -r 2fb399422f13 -r 2abda0567efe bin/csh/csh.c
--- a/bin/csh/csh.c Wed Sep 14 07:37:05 2022 +0000
+++ b/bin/csh/csh.c Wed Sep 14 16:15:51 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: csh.c,v 1.53 2020/08/09 00:53:38 dholland Exp $ */
+/* $NetBSD: csh.c,v 1.54 2022/09/14 16:15:51 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
#else
-__RCSID("$NetBSD: csh.c,v 1.53 2020/08/09 00:53:38 dholland Exp $");
+__RCSID("$NetBSD: csh.c,v 1.54 2022/09/14 16:15:51 christos Exp $");
#endif
#endif /* not lint */
@@ -1153,6 +1153,8 @@
seterr = NULL;
}
+ updateediting();
+
/*
* Echo not only on VERBOSE, but also with history expansion. If there
* is a lexical error then we forego history echo.
diff -r 2fb399422f13 -r 2abda0567efe bin/csh/extern.h
--- a/bin/csh/extern.h Wed Sep 14 07:37:05 2022 +0000
+++ b/bin/csh/extern.h Wed Sep 14 16:15:51 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.32 2020/04/23 07:54:53 simonb Exp $ */
+/* $NetBSD: extern.h,v 1.33 2022/09/14 16:15:51 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -291,6 +291,7 @@
void setNS(Char *);
void shift(Char **, struct command *);
void plist(struct varent *);
+void updateediting(void);
/*
* time.c
diff -r 2fb399422f13 -r 2abda0567efe bin/csh/set.c
--- a/bin/csh/set.c Wed Sep 14 07:37:05 2022 +0000
+++ b/bin/csh/set.c Wed Sep 14 16:15:51 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: set.c,v 1.38 2021/08/15 12:16:02 christos Exp $ */
+/* $NetBSD: set.c,v 1.39 2022/09/14 16:15:51 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: set.c,v 1.38 2021/08/15 12:16:02 christos Exp $");
+__RCSID("$NetBSD: set.c,v 1.39 2022/09/14 16:15:51 christos Exp $");
#endif
#endif /* not lint */
@@ -59,6 +59,8 @@
static void exportpath(Char **);
static void balance(struct varent *, int, int);
+static int wantediting;
+
#ifdef EDIT
static const char *
alias_text(void *dummy __unused, const char *name)
@@ -148,26 +150,8 @@
filec = 1;
#endif
#ifdef EDIT
- else if (eq(vp, STRedit)) {
- HistEvent ev;
- Char *vn = value(STRhistchars);
-
- editing = 1;
- el = el_init_fd(getprogname(), cshin, cshout, csherr,
- SHIN, SHOUT, SHERR);
- el_set(el, EL_EDITOR, *vn ? short2str(vn) : "emacs");
- el_set(el, EL_PROMPT, printpromptstr);
- el_set(el, EL_ALIAS_TEXT, alias_text, NULL);
- el_set(el, EL_SAFEREAD, 1);
- el_set(el, EL_ADDFN, "rl-complete",
- "ReadLine compatible completion function", _el_fn_complete);
- el_set(el, EL_BIND, "^I", adrof(STRfilec) ? "rl-complete" : "ed-insert",
- NULL);
- hi = history_init();
- history(hi, &ev, H_SETSIZE, getn(value(STRhistory)));
- loadhist(Histlist.Hnext);
- el_set(el, EL_HIST, history, hi);
- }
+ else if (eq(vp, STRedit))
+ wantediting = 1;
#endif
}
@@ -566,16 +550,45 @@
filec = 0;
#endif
#ifdef EDIT
- if (adrof(STRedit) == 0) {
+ if (adrof(STRedit) == 0)
+ wantediting = 0;
+#endif
+}
+
+extern int insource;
+void
+updateediting(void)
+{
+ if (insource || wantediting == editing)
+ return;
+
+ if (wantediting) {
+ HistEvent ev;
+ Char *vn = value(STRhistchars);
+
+ el = el_init_fd(getprogname(), cshin, cshout, csherr,
+ SHIN, SHOUT, SHERR);
+ el_set(el, EL_EDITOR, *vn ? short2str(vn) : "emacs");
+ el_set(el, EL_PROMPT, printpromptstr);
+ el_set(el, EL_ALIAS_TEXT, alias_text, NULL);
+ el_set(el, EL_SAFEREAD, 1);
+ el_set(el, EL_ADDFN, "rl-complete",
+ "ReadLine compatible completion function", _el_fn_complete);
+ el_set(el, EL_BIND, "^I", adrof(STRfilec) ? "rl-complete" : "ed-insert",
+ NULL);
+ hi = history_init();
+ history(hi, &ev, H_SETSIZE, getn(value(STRhistory)));
+ loadhist(Histlist.Hnext);
+ el_set(el, EL_HIST, history, hi);
+ } else {
if (el)
el_end(el);
if (hi)
history_end(hi);
el = NULL;
hi = NULL;
- editing = 0;
}
-#endif
+ editing = wantediting;
}
void
Home |
Main Index |
Thread Index |
Old Index