Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Properly support EDITRC - use it as (naming) the file...



details:   https://anonhg.NetBSD.org/src/rev/4fad9c2e3cb6
branches:  trunk
changeset: 825026:4fad9c2e3cb6
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Jun 27 02:22:08 2017 +0000

description:
Properly support EDITRC - use it as (naming) the file when setting
up libedit, and re-do the config whenever EDITRC is set.

diffstat:

 bin/sh/histedit.c   |  12 +++++++++---
 bin/sh/myhistedit.h |   3 ++-
 bin/sh/sh.1         |  36 +++++++++++++++++++++++++++++++++++-
 bin/sh/var.c        |   7 +++++--
 bin/sh/var.h        |   3 ++-
 5 files changed, 53 insertions(+), 8 deletions(-)

diffs (165 lines):

diff -r 3f98491c2922 -r 4fad9c2e3cb6 bin/sh/histedit.c
--- a/bin/sh/histedit.c Tue Jun 27 01:22:58 2017 +0000
+++ b/bin/sh/histedit.c Tue Jun 27 02:22:08 2017 +0000
@@ -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 @@
                                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 @@
        }
 }
 
+void
+set_editrc(const char *fname)
+{
+       if (iflag && editing && el)
+               el_source(el, fname);
+}
 
 void
 sethistsize(const char *hs)
diff -r 3f98491c2922 -r 4fad9c2e3cb6 bin/sh/myhistedit.h
--- a/bin/sh/myhistedit.h       Tue Jun 27 01:22:58 2017 +0000
+++ b/bin/sh/myhistedit.h       Tue Jun 27 02:22:08 2017 +0000
@@ -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 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);
 
diff -r 3f98491c2922 -r 4fad9c2e3cb6 bin/sh/sh.1
--- a/bin/sh/sh.1       Tue Jun 27 01:22:58 2017 +0000
+++ b/bin/sh/sh.1       Tue Jun 27 02:22:08 2017 +0000
@@ -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
 .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
diff -r 3f98491c2922 -r 4fad9c2e3cb6 bin/sh/var.c
--- a/bin/sh/var.c      Tue Jun 27 01:22:58 2017 +0000
+++ b/bin/sh/var.c      Tue Jun 27 02:22:08 2017 +0000
@@ -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 @@
 #ifndef SMALL
 struct var vhistsize;
 struct var vterm;
+struct var editrc;
 #endif
 struct var vifs;
 struct var vmail;
@@ -139,6 +140,8 @@
 #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 } },
diff -r 3f98491c2922 -r 4fad9c2e3cb6 bin/sh/var.h
--- a/bin/sh/var.h      Tue Jun 27 01:22:58 2017 +0000
+++ b/bin/sh/var.h      Tue Jun 27 02:22:08 2017 +0000
@@ -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 vps2;
 extern struct var vps4;
 extern struct var line_num;
+extern struct var editrc;
 #ifndef SMALL
 extern struct var vterm;
 extern struct var vtermcap;



Home | Main Index | Thread Index | Old Index