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
This commit is contained in:
Tim J. Robbins 2002-07-23 11:50:53 +00:00
parent 95ad74d7cf
commit 088acf9001
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100565
4 changed files with 24 additions and 0 deletions

View File

@ -92,3 +92,4 @@ waitcmd wait
aliascmd alias
ulimitcmd ulimit
testcmd test [
bindcmd bind

View File

@ -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

View File

@ -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 **);

View File

@ -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 ,