From f9fd5faa32d9a7f2b556f323090c9b6f2489ab61 Mon Sep 17 00:00:00 2001 From: tjr Date: Tue, 23 Jul 2002 11:50:53 +0000 Subject: Add a `bind' builtin command, which is simply a wrapper around libedit's builtin command of the same name. This allows the key bindings for the shell's line editor to be changed. MFC after: 2 weeks --- bin/sh/builtins.def | 1 + bin/sh/histedit.c | 18 ++++++++++++++++++ bin/sh/myhistedit.h | 1 + bin/sh/sh.1 | 4 ++++ 4 files changed, 24 insertions(+) (limited to 'bin') diff --git a/bin/sh/builtins.def b/bin/sh/builtins.def index 2410425..233e25f 100644 --- a/bin/sh/builtins.def +++ b/bin/sh/builtins.def @@ -92,3 +92,4 @@ waitcmd wait aliascmd alias ulimitcmd ulimit testcmd test [ +bindcmd bind diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index 37a10bf..ae39c0b 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -480,6 +480,16 @@ str_to_event(char *str, int last) } return (he.num); } + +int +bindcmd(int argc, char **argv) +{ + + if (el == NULL) + error("line editing is disabled"); + return (el_parse(el, argc, argv)); +} + #else #include "error.h" @@ -491,4 +501,12 @@ histcmd(int argc, char **argv) /*NOTREACHED*/ return (0); } + +int +bindcmd(int argc, char **argv) +{ + + error("not compiled with line editing support"); + return (0); +} #endif diff --git a/bin/sh/myhistedit.h b/bin/sh/myhistedit.h index 77817c7..644b2c0 100644 --- a/bin/sh/myhistedit.h +++ b/bin/sh/myhistedit.h @@ -45,4 +45,5 @@ void sethistsize(const char *); int histcmd(int, char **); int not_fcnumber(char *); int str_to_event(char *, int); +int bindcmd(int, char **); diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 369b5f3..38410d0 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -1279,6 +1279,10 @@ Execute the specified builtin command, .Ar cmd . This is useful when the user wishes to override a shell function with the same name as a builtin command. +.It Ic bind Oo Fl aeklrsv Oc Oo Ar key Oo Ar command Oc Oc +List or alter key bindings for the line editor. +This command is documented in +.Xr editrc 5 . .It Ic cd Oo Fl LP Oc Op Ar directory Switch to the specified .Ar directory , -- cgit v1.1