If 'set -o tabcomplete' it set, then bind <tab> to the libedit filename
completion function. Note that the libedit code will probably want fine-tuning! While editing the man page, add a note that non-whitespace IFS chars are terminators and can generate null arguments.
This commit is contained in:
parent
7d0b65d656
commit
82537bf8e8
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: histedit.c,v 1.34 2003/10/27 06:19:29 lukem Exp $ */
|
||||
/* $NetBSD: histedit.c,v 1.35 2005/05/07 19:52:17 dsl 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.34 2003/10/27 06:19:29 lukem Exp $");
|
||||
__RCSID("$NetBSD: histedit.c,v 1.35 2005/05/07 19:52:17 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -69,6 +69,7 @@ History *hist; /* history cookie */
|
|||
EditLine *el; /* editline cookie */
|
||||
int displayhist;
|
||||
static FILE *el_in, *el_out;
|
||||
unsigned char _el_fn_complete(EditLine *, int);
|
||||
|
||||
STATIC const char *fc_replace(const char *, char *, char *);
|
||||
|
||||
|
@ -149,6 +150,12 @@ bad:
|
|||
el_set(el, EL_EDITOR, "vi");
|
||||
else if (Eflag)
|
||||
el_set(el, EL_EDITOR, "emacs");
|
||||
if (tabcomplete) {
|
||||
el_set(el, EL_ADDFN, "rl_complete",
|
||||
"ReadLine compatible completion function",
|
||||
_el_fn_complete);
|
||||
el_set(el, EL_BIND, "^I", "rl_complete", NULL);
|
||||
}
|
||||
el_source(el, NULL);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: options.h,v 1.17 2003/08/07 09:05:36 agc Exp $ */
|
||||
/* $NetBSD: options.h,v 1.18 2005/05/07 19:52:17 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -97,9 +97,11 @@ DEF_OPT( "nolog", 0 ) /* [U] no functon defs in command history */
|
|||
#define nolog optlist[16].val
|
||||
DEF_OPT( "cdprint", 0 ) /* always print result of cd */
|
||||
#define cdprint optlist[17].val
|
||||
DEF_OPT( "tabcomplete", 0 ) /* <tab> causes filename expansion */
|
||||
#define tabcomplete optlist[18].val
|
||||
#ifdef DEBUG
|
||||
DEF_OPT( "debug", 0 ) /* enable debug prints */
|
||||
#define debug optlist[18].val
|
||||
#define debug optlist[19].val
|
||||
#endif
|
||||
|
||||
#ifdef DEFINE_OPTIONS
|
||||
|
|
27
bin/sh/sh.1
27
bin/sh/sh.1
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: sh.1,v 1.78 2004/06/03 19:54:37 hubertf Exp $
|
||||
.\" $NetBSD: sh.1,v 1.79 2005/05/07 19:52:17 dsl Exp $
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
|
@ -31,7 +31,7 @@
|
|||
.\"
|
||||
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
|
||||
.\"
|
||||
.Dd April 17, 2004
|
||||
.Dd May 7, 2005
|
||||
.Os
|
||||
.Dt SH 1
|
||||
.Sh NAME
|
||||
|
@ -304,6 +304,12 @@ Make an interactive shell always print the new directory name when
|
|||
changed by the
|
||||
.Ic cd
|
||||
command.
|
||||
.It "\ \ " Em tabcomplete
|
||||
Enables filename completion in the command line editor.
|
||||
Typing a tab character will extend the current input word to match a
|
||||
filename.
|
||||
If more than one filename matches it is only extended to be the common prefix.
|
||||
Typing a second tab character will list all the matching names.
|
||||
.El
|
||||
.Ss Lexical Structure
|
||||
The shell reads input in terms of lines from a file and breaks it up into
|
||||
|
@ -945,7 +951,7 @@ If a parameter expansion occurs inside double-quotes:
|
|||
Pathname expansion is not performed on the results of the expansion.
|
||||
.It
|
||||
Field splitting is not performed on the results of the
|
||||
expansion, with the exception of @.
|
||||
expansion, with the exception of the special rules for @.
|
||||
.El
|
||||
.Pp
|
||||
In addition, a parameter expansion can be modified by using one of the
|
||||
|
@ -1068,6 +1074,17 @@ The shell treats each character of the
|
|||
.Ev IFS
|
||||
as a delimiter and use the delimiters to split the results of parameter
|
||||
expansion and command substitution into fields.
|
||||
.Pp
|
||||
None whitespace characters in
|
||||
.Ev IFS
|
||||
are treated strictly as parameter terminators.
|
||||
So adjacent non whitespace
|
||||
.Ev IFS
|
||||
characters will produce empty parameters.
|
||||
.Pp
|
||||
If
|
||||
.Ev IFS
|
||||
is unset it is assumed to contain space, tab and newline.
|
||||
.Ss Pathname Expansion (File Name Generation)
|
||||
Unless the
|
||||
.Fl f
|
||||
|
@ -1926,3 +1943,7 @@ significant security risk.
|
|||
.Pp
|
||||
PS1, PS2, and PS4 should be subject to parameter expansion before
|
||||
being displayed.
|
||||
.Pp
|
||||
The characters generated by filename completion should probably be quoted
|
||||
to ensure that the filename is still valid after the input line has been
|
||||
processed.
|
||||
|
|
Loading…
Reference in New Issue