Project

General

Profile

Bug #1281 ยป sh-tabcomplete.diff

qhwt+dfly, 03/29/2009 06:09 AM

View differences:

bin/sh/histedit.c
EditLine *el; /* editline cookie */
int displayhist;
static FILE *el_in, *el_out, *el_err;
unsigned char _el_fn_complete(EditLine *, int);
STATIC char *fc_replace(const char *, char *, char *);
......
if (hist)
el_set(el, EL_HIST, history, hist);
el_set(el, EL_PROMPT, getprompt);
el_set(el, EL_ADDFN, "rl-complete",
"ReadLine compatible completion function",
_el_fn_complete);
} else {
bad:
out2str("sh: can't initialize editing\n");
......
el_set(el, EL_EDITOR, "vi");
else if (Eflag)
el_set(el, EL_EDITOR, "emacs");
el_set(el, EL_BIND, "^I",
tabcomplete ? "rl-complete" : "ed-insert", NULL);
el_source(el, NULL);
}
} else {
bin/sh/options.c
iflag = 1;
if (mflag == 2)
mflag = iflag;
/* turn on tabcomplete in an interactive shell by default */
tabcomplete = iflag;
for (i = 0; i < NOPTS; i++)
if (optlist[i].val == 2)
optlist[i].val = 0;
bin/sh/options.h
#define privileged optlist[15].val
#define Tflag optlist[16].val
#define Pflag optlist[17].val
#define tabcomplete optlist[18].val
#define NOPTS 18
#define NOPTS 19
struct optent {
const char *name;
......
{ "privileged", 'p', 0 },
{ "trapsasync", 'T', 0 },
{ "physical", 'P', 0 },
{ "tabcomplete", '\0', 0 },
};
#else
extern struct optent optlist[NOPTS];
bin/sh/sh.1
variable)
to standard error before it is executed.
Useful for debugging.
.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.
Turned on by default in an interactive shell.
.El
.Pp
The
......
The
.Nm
utility does not recognize multibyte characters.
.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.
    (1-1/1)