NetBSD Problem Report #10097
Received: (qmail 23010 invoked from network); 11 May 2000 07:13:48 -0000
Message-Id: <200005110714.e4B7EdU01224@nocturne.fast.no>
Date: Thu, 11 May 2000 09:14:39 +0200 (CEST)
From: Arne H Juul <arnej@fast.no>
Reply-To: arnej@fast.no
To: gnats-bugs@gnats.netbsd.org
Subject: key bindings and editrc for /bin/sh
X-Send-Pr-Version: 3.95
>Number: 10097
>Category: bin
>Synopsis: key bindings and editrc for /bin/sh
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Thu May 11 07:14:00 +0000 2000
>Closed-Date: Sun May 04 01:06:12 +0000 2003
>Last-Modified: Sun May 04 01:07:00 +0000 2003
>Originator: Arne H Juul
>Release: NetBSD-current as of yesterday (2000-05-10)
>Organization:
>Environment:
System: NetBSD nocturne.fast.no 1.4Y NetBSD 1.4Y (NOCTURNE) #0: Wed May 10 23:46:24 CEST 2000 arnej@nocturne.fast.no:/usr/src/sys/arch/i386/compile/NOCTURNE i386
>Description:
While /bin/sh uses editline, but does not use the editrc(5)
functionality. In addition, there's no way to give editline
commands or make it read an editrc-style file.
>How-To-Repeat:
run sh -E or sh; set -o emacs; try to make ^w behave sensibly.
note that editrc(5) manpage seems very promising but that sh(1)
manpage says nothing about how to change key bindings. beat
head against wall.
>Fix:
The following patch to /bin/sh adds an "inputrc" builtin
to read editrc-style commands, and also reads in ~/.editrc
at editor startup. Please apply.
Index: builtins.def
===================================================================
RCS file: /rst/nb-cvs/basesrc/bin/sh/builtins.def,v
retrieving revision 1.15
diff -u -u -r1.15 builtins.def
--- builtins.def 2000/04/09 23:27:03 1.15
+++ builtins.def 2000/05/01 10:11:30
@@ -52,6 +52,7 @@
bltincmd command
#alloccmd alloc
bgcmd -j bg
+inputrc inputrc
breakcmd break continue
#catfcmd catf
cdcmd cd chdir
Index: histedit.c
===================================================================
RCS file: /rst/nb-cvs/basesrc/bin/sh/histedit.c,v
retrieving revision 1.23
diff -u -u -r1.23 histedit.c
--- histedit.c 2000/04/14 05:52:58 1.23
+++ histedit.c 2000/05/01 10:13:05
@@ -128,10 +128,18 @@
INTON;
}
if (el) {
+ char *home;
+ char path[MAXPATHLEN];
+
if (Vflag)
el_set(el, EL_EDITOR, "vi");
else if (Eflag)
el_set(el, EL_EDITOR, "emacs");
+ if ((home = lookupvar("HOME")) != NULL) {
+ strlcpy(path, home, MAXPATHLEN);
+ strlcat(path, "/.editrc", MAXPATHLEN);
+ el_source(el, path);
+ }
}
} else {
INTOFF;
@@ -172,6 +180,27 @@
outfmt(out2, "sh: Can't set terminal type %s\n", term);
outfmt(out2, "sh: Using dumb terminal settings.\n");
}
+}
+
+int
+inputrc(argc, argv)
+ int argc;
+ char **argv;
+{
+ if (argc != 2) {
+ out2str("usage: inputrc file\n");
+ return 1;
+ }
+ if (el != NULL) {
+ if (el_source(el, argv[1])) {
+ out2str("inputrc: failed\n");
+ return 1;
+ } else
+ return 0;
+ } else {
+ out2str("sh: inputrc ignored, not editing\n");
+ return 1;
+ }
}
/*
Index: myhistedit.h
===================================================================
RCS file: /rst/nb-cvs/basesrc/bin/sh/myhistedit.h,v
retrieving revision 1.7
diff -u -u -r1.7 myhistedit.h
--- myhistedit.h 1999/07/09 03:05:50 1.7
+++ myhistedit.h 2000/03/31 04:50:20
@@ -45,6 +45,7 @@
void sethistsize __P((const char *));
void setterm __P((const char *));
int histcmd __P((int, char **));
+int inputrc __P((int, char **));
int not_fcnumber __P((char *));
int str_to_event __P((const char *, int));
Index: sh.1
===================================================================
RCS file: /rst/nb-cvs/basesrc/bin/sh/sh.1,v
retrieving revision 1.33
diff -u -u -r1.33 sh.1
--- sh.1 1999/11/16 22:03:25 1.33
+++ sh.1 2000/05/01 10:24:27
@@ -1238,6 +1238,11 @@
.Fl r
option causes the hash command to delete all the entries in the hash table
except for functions.
+.It inputrc Ar file
+Read the
+.Va file
+to set keybindings as defined by
+.Xr editrc 5 .
.It jobid Op Ar job
Print the process id's of the processes in the job.
If the job argument is omitted, use the current job.
@@ -1504,6 +1509,7 @@
.El
.Sh SEE ALSO
.Xr csh 1 ,
+.Xr editrc 5 ,
.Xr getopt 1 ,
.Xr ksh 1 ,
.Xr login 1 ,
>Release-Note:
>Audit-Trail:
From: Gregory McGarry <g.mcgarry@ieee.org>
To: arnej@fast.no
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/10097: key bindings and editrc for /bin/sh
Date: Fri, 2 May 2003 21:05:10 +1200
Has this now been fixed in the editline library. editline(3)
indicates that ~/.editrc is the default file.
Is the only remaining issue that the inputrc command should be
added to sh(1)?
-- Gregory McGarry <g.mcgarry@ieee.org>
From: Arne H Juul <Arne.Juul@overture.com>
To: Gregory McGarry <g.mcgarry@ieee.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/10097: key bindings and editrc for /bin/sh
Date: Fri, 2 May 2003 12:28:36 +0200 (CEST)
On Fri, 2 May 2003, Gregory McGarry wrote:
> Has this now been fixed in the editline library. editline(3)
> indicates that ~/.editrc is the default file.
Yes, I think this part is OK.
> Is the only remaining issue that the inputrc command should be
> added to sh(1)?
Yep, that's the patch I have remaining in my tree at least:
Index: builtins.def
===================================================================
RCS file: /rst/nb-cvs/src/bin/sh/builtins.def,v
retrieving revision 1.16
diff -u -u -r1.16 builtins.def
--- builtins.def 24 Nov 2002 22:35:39 -0000 1.16
+++ builtins.def 1 Dec 2002 01:06:30 -0000
@@ -62,6 +62,7 @@
exportcmd -s export -s readonly
falsecmd -u false
histcmd -h -u fc
+inputrc inputrc
fgcmd -j -u fg
getoptscmd -u getopts
hashcmd hash
Index: histedit.c
===================================================================
RCS file: /rst/nb-cvs/src/bin/sh/histedit.c,v
retrieving revision 1.27
diff -u -u -r1.27 histedit.c
--- histedit.c 24 Nov 2002 22:35:40 -0000 1.27
+++ histedit.c 2 May 2003 10:29:52 -0000
@@ -183,6 +183,27 @@
}
}
+int
+inputrc(argc, argv)
+ int argc;
+ char **argv;
+{
+ if (argc != 2) {
+ out2str("usage: inputrc file\n");
+ return 1;
+ }
+ if (el != NULL) {
+ if (el_source(el, argv[1])) {
+ out2str("inputrc: failed\n");
+ return 1;
+ } else
+ return 0;
+ } else {
+ out2str("sh: inputrc ignored, not editing\n");
+ return 1;
+ }
+}
+
/*
* This command is provided since POSIX decided to standardize
* the Korn shell fc command. Oh well...
@@ -499,6 +520,14 @@
#else
int
histcmd(int argc, char **argv)
+{
+ error("not compiled with history support");
+ /* NOTREACHED */
+}
+int
+inputrc(int argc, char **argv)
+ int argc;
+ char **argv;
{
error("not compiled with history support");
/* NOTREACHED */
Index: myhistedit.h
===================================================================
RCS file: /rst/nb-cvs/src/bin/sh/myhistedit.h,v
retrieving revision 1.8
diff -u -u -r1.8 myhistedit.h
--- myhistedit.h 24 Nov 2002 22:35:42 -0000 1.8
+++ myhistedit.h 1 Dec 2002 01:09:49 -0000
@@ -45,6 +45,7 @@
void sethistsize(const char *);
void setterm(const char *);
int histcmd(int, char **);
+int inputrc(int, char **);
int not_fcnumber(char *);
int str_to_event(const char *, int);
Index: sh.1
===================================================================
RCS file: /rst/nb-cvs/src/bin/sh/sh.1,v
retrieving revision 1.58
diff -u -u -r1.58 sh.1
--- sh.1 23 Jan 2003 18:32:07 -0000 1.58
+++ sh.1 1 Feb 2003 15:31:27 -0000
@@ -1449,6 +1449,11 @@
.Fl r
option causes the hash command to delete all the entries in the hash table
except for functions.
+.It inputrc Ar file
+Read the
+.Va file
+to set keybindings as defined by
+.Xr editrc 5 .
.It jobid Op Ar job
Print the process id's of the processes in the job.
If the
@@ -1820,6 +1825,7 @@
.Sh SEE ALSO
.Xr csh 1 ,
.Xr echo 1 ,
+.Xr editrc 5 ,
.Xr getopt 1 ,
.Xr ksh 1 ,
.Xr login 1 ,
--
Arne H Juul Mail: Arne.Juul@overture.com
System administrator Web: http://www.overture.com/
Fast Search & Transfer Phone: +47 7320 1219
Sverresgate 15, 7013 Trondheim Fax: +47 7320 1201
State-Changed-From-To: open->closed
State-Changed-By: gmcgarry
State-Changed-When: Sun May 4 01:05:49 UTC 2003
State-Changed-Why:
Applied patch.
From: Gregory McGarry <gmcgarry@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: pr/10097 CVS commit: src/bin/sh
Date: Sun, 4 May 2003 01:05:25 +0000 (UTC)
Module Name: src
Committed By: gmcgarry
Date: Sun May 4 01:05:25 UTC 2003
Modified Files:
src/bin/sh: builtins.def histedit.c myhistedit.h sh.1
Log Message:
Add new builtin 'inputrc' which allows keybindings to be redefined
for the current shell. From Arne H Juul in PR#10097.
To generate a diff of this commit:
cvs rdiff -r1.16 -r1.17 src/bin/sh/builtins.def
cvs rdiff -r1.27 -r1.28 src/bin/sh/histedit.c
cvs rdiff -r1.8 -r1.9 src/bin/sh/myhistedit.h
cvs rdiff -r1.64 -r1.65 src/bin/sh/sh.1
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.