Module Name: src
Committed By: christos
Date: Wed Sep 14 16:15:52 UTC 2022
Modified Files:
src/bin/csh: csh.c extern.h set.c
Log Message:
defer editing setup/cleanup to when we are interactive.
To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/bin/csh/csh.c
cvs rdiff -u -r1.32 -r1.33 src/bin/csh/extern.h
cvs rdiff -u -r1.38 -r1.39 src/bin/csh/set.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/csh/csh.c
diff -u src/bin/csh/csh.c:1.53 src/bin/csh/csh.c:1.54
--- src/bin/csh/csh.c:1.53 Sat Aug 8 20:53:38 2020
+++ src/bin/csh/csh.c Wed Sep 14 12:15:51 2022
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
#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 @@ process(int catch)
seterr = NULL;
}
+ updateediting();
+
/*
* Echo not only on VERBOSE, but also with history expansion. If there
* is a lexical error then we forego history echo.
Index: src/bin/csh/extern.h
diff -u src/bin/csh/extern.h:1.32 src/bin/csh/extern.h:1.33
--- src/bin/csh/extern.h:1.32 Thu Apr 23 03:54:53 2020
+++ src/bin/csh/extern.h Wed Sep 14 12:15:51 2022
@@ -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 unsetv(Char *);
void setNS(Char *);
void shift(Char **, struct command *);
void plist(struct varent *);
+void updateediting(void);
/*
* time.c
Index: src/bin/csh/set.c
diff -u src/bin/csh/set.c:1.38 src/bin/csh/set.c:1.39
--- src/bin/csh/set.c:1.38 Sun Aug 15 08:16:02 2021
+++ src/bin/csh/set.c Wed Sep 14 12:15:51 2022
@@ -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 unsetv1(struct varent *);
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 @@ update_vars(Char *vp)
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 @@ unset(Char **v, struct command *t)
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