Module Name: src
Committed By: kre
Date: Tue Jun 27 02:22:08 UTC 2017
Modified Files:
src/bin/sh: histedit.c myhistedit.h sh.1 var.c var.h
Log Message:
Properly support EDITRC - use it as (naming) the file when setting
up libedit, and re-do the config whenever EDITRC is set.
To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/bin/sh/histedit.c
cvs rdiff -u -r1.11 -r1.12 src/bin/sh/myhistedit.h
cvs rdiff -u -r1.152 -r1.153 src/bin/sh/sh.1
cvs rdiff -u -r1.60 -r1.61 src/bin/sh/var.c
cvs rdiff -u -r1.32 -r1.33 src/bin/sh/var.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/histedit.c
diff -u src/bin/sh/histedit.c:1.49 src/bin/sh/histedit.c:1.50
--- src/bin/sh/histedit.c:1.49 Mon Jun 26 20:28:01 2017
+++ src/bin/sh/histedit.c Tue Jun 27 02:22:08 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.c,v 1.49 2017/06/26 20:28:01 christos Exp $ */
+/* $NetBSD: histedit.c,v 1.50 2017/06/27 02:22:08 kre Exp $ */
/*-
* Copyright (c) 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: histedit.c,v 1.49 2017/06/26 20:28:01 christos Exp $");
+__RCSID("$NetBSD: histedit.c,v 1.50 2017/06/27 02:22:08 kre Exp $");
#endif
#endif /* not lint */
@@ -158,7 +158,7 @@ bad:
el_set(el, EL_EDITOR, "emacs");
el_set(el, EL_BIND, "^I",
tabcomplete ? "rl-complete" : "ed-insert", NULL);
- el_source(el, NULL);
+ el_source(el, lookupvar("EDITRC"));
}
} else {
INTOFF;
@@ -174,6 +174,12 @@ bad:
}
}
+void
+set_editrc(const char *fname)
+{
+ if (iflag && editing && el)
+ el_source(el, fname);
+}
void
sethistsize(const char *hs)
Index: src/bin/sh/myhistedit.h
diff -u src/bin/sh/myhistedit.h:1.11 src/bin/sh/myhistedit.h:1.12
--- src/bin/sh/myhistedit.h:1.11 Sat Jun 18 21:18:46 2011
+++ src/bin/sh/myhistedit.h Tue Jun 27 02:22:08 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: myhistedit.h,v 1.11 2011/06/18 21:18:46 christos Exp $ */
+/* $NetBSD: myhistedit.h,v 1.12 2017/06/27 02:22:08 kre Exp $ */
/*-
* Copyright (c) 1993
@@ -41,6 +41,7 @@ void histedit(void);
void sethistsize(const char *);
void setterm(const char *);
int inputrc(int, char **);
+void set_editrc(const char *);
int not_fcnumber(char *);
int str_to_event(const char *, int);
Index: src/bin/sh/sh.1
diff -u src/bin/sh/sh.1:1.152 src/bin/sh/sh.1:1.153
--- src/bin/sh/sh.1:1.152 Sat Jun 17 07:50:35 2017
+++ src/bin/sh/sh.1 Tue Jun 27 02:22:08 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: sh.1,v 1.152 2017/06/17 07:50:35 kre Exp $
+.\" $NetBSD: sh.1,v 1.153 2017/06/27 02:22:08 kre Exp $
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -2750,12 +2750,46 @@ and the default settings in
and
.Ar vi
modes.
+Also see
+.Xr editrc 5
+for the commands that can be given to configure
+.Xr editline 7
+in the file named by the
+.Ev EDITRC
+parameter, or using
+.Xr editline 7 Ns \&'s
+configuration command line.
.Sh ENVIRONMENT
.Bl -tag -width MAILCHECK
.It Ev CDPATH
The search path used with the
.Ic cd
built-in.
+.It Ev EDITRC
+Gives the name of the file containing commands for
+.Xr editline 7 .
+See
+.Xr editrc 5
+for possible content and format.
+The file is processed, when in interactive mode with
+command line editing enabled, whenever
+.Ev EDITRC
+is set (even with no actual value change,)
+and if command line editing changes from disabled to enabled,
+or the editor style used is changed.
+(See the
+.Fl E
+and
+.Fl V
+options of the
+.Ic set
+builtin command, described in
+.Sx Built-ins
+above, which are documented further above in
+.Sx Argument List Processing . )
+If unset
+.Dq $HOME/.editrc
+is used.
.It Ev HISTSIZE
The number of lines in the history buffer for the shell.
.It Ev HOME
Index: src/bin/sh/var.c
diff -u src/bin/sh/var.c:1.60 src/bin/sh/var.c:1.61
--- src/bin/sh/var.c:1.60 Sat Jun 17 10:46:34 2017
+++ src/bin/sh/var.c Tue Jun 27 02:22:08 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.60 2017/06/17 10:46:34 kre Exp $ */
+/* $NetBSD: var.c,v 1.61 2017/06/27 02:22:08 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: var.c,v 1.60 2017/06/17 10:46:34 kre Exp $");
+__RCSID("$NetBSD: var.c,v 1.61 2017/06/27 02:22:08 kre Exp $");
#endif
#endif /* not lint */
@@ -95,6 +95,7 @@ struct localvar *localvars;
#ifndef SMALL
struct var vhistsize;
struct var vterm;
+struct var editrc;
#endif
struct var vifs;
struct var vmail;
@@ -139,6 +140,8 @@ const struct varinit varinit[] = {
#ifndef SMALL
{ &vterm, VSTRFIXED|VTEXTFIXED|VUNSET, "TERM=",
{ .set_func= setterm } },
+ { &editrc, VSTRFIXED|VTEXTFIXED|VUNSET, "EDITRC=",
+ { .set_func= set_editrc } },
#endif
{ &voptind, VSTRFIXED|VTEXTFIXED|VNOFUNC, "OPTIND=1",
{ .set_func= getoptsreset } },
Index: src/bin/sh/var.h
diff -u src/bin/sh/var.h:1.32 src/bin/sh/var.h:1.33
--- src/bin/sh/var.h:1.32 Mon Jun 26 22:09:16 2017
+++ src/bin/sh/var.h Tue Jun 27 02:22:08 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: var.h,v 1.32 2017/06/26 22:09:16 kre Exp $ */
+/* $NetBSD: var.h,v 1.33 2017/06/27 02:22:08 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -89,6 +89,7 @@ extern struct var vps1;
extern struct var vps2;
extern struct var vps4;
extern struct var line_num;
+extern struct var editrc;
#ifndef SMALL
extern struct var vterm;
extern struct var vtermcap;