sh-tabcomplete.diff
| b/bin/sh/histedit.c | ||
|---|---|---|
| 67 | 67 |
EditLine *el; /* editline cookie */ |
| 68 | 68 |
int displayhist; |
| 69 | 69 |
static FILE *el_in, *el_out, *el_err; |
| 70 |
unsigned char _el_fn_complete(EditLine *, int); |
|
| 70 | 71 | |
| 71 | 72 |
STATIC char *fc_replace(const char *, char *, char *); |
| 72 | 73 | |
| ... | ... | |
| 124 | 125 |
if (hist) |
| 125 | 126 |
el_set(el, EL_HIST, history, hist); |
| 126 | 127 |
el_set(el, EL_PROMPT, getprompt); |
| 128 |
el_set(el, EL_ADDFN, "rl-complete", |
|
| 129 |
"ReadLine compatible completion function", |
|
| 130 |
_el_fn_complete); |
|
| 127 | 131 |
} else {
|
| 128 | 132 |
bad: |
| 129 | 133 |
out2str("sh: can't initialize editing\n");
|
| ... | ... | |
| 140 | 144 |
el_set(el, EL_EDITOR, "vi"); |
| 141 | 145 |
else if (Eflag) |
| 142 | 146 |
el_set(el, EL_EDITOR, "emacs"); |
| 147 |
el_set(el, EL_BIND, "^I", |
|
| 148 |
tabcomplete ? "rl-complete" : "ed-insert", NULL); |
|
| 143 | 149 |
el_source(el, NULL); |
| 144 | 150 |
} |
| 145 | 151 |
} else {
|
| b/bin/sh/options.c | ||
|---|---|---|
| 97 | 97 |
iflag = 1; |
| 98 | 98 |
if (mflag == 2) |
| 99 | 99 |
mflag = iflag; |
| 100 |
/* turn on tabcomplete in an interactive shell by default */ |
|
| 101 |
tabcomplete = iflag; |
|
| 100 | 102 |
for (i = 0; i < NOPTS; i++) |
| 101 | 103 |
if (optlist[i].val == 2) |
| 102 | 104 |
optlist[i].val = 0; |
| b/bin/sh/options.h | ||
|---|---|---|
| 67 | 67 |
#define privileged optlist[15].val |
| 68 | 68 |
#define Tflag optlist[16].val |
| 69 | 69 |
#define Pflag optlist[17].val |
| 70 |
#define tabcomplete optlist[18].val |
|
| 70 | 71 | |
| 71 |
#define NOPTS 18
|
|
| 72 |
#define NOPTS 19
|
|
| 72 | 73 | |
| 73 | 74 |
struct optent {
|
| 74 | 75 |
const char *name; |
| ... | ... | |
| 96 | 97 |
{ "privileged", 'p', 0 },
|
| 97 | 98 |
{ "trapsasync", 'T', 0 },
|
| 98 | 99 |
{ "physical", 'P', 0 },
|
| 100 |
{ "tabcomplete", '\0', 0 },
|
|
| 99 | 101 |
}; |
| 100 | 102 |
#else |
| 101 | 103 |
extern struct optent optlist[NOPTS]; |
| b/bin/sh/sh.1 | ||
|---|---|---|
| 315 | 315 |
variable) |
| 316 | 316 |
to standard error before it is executed. |
| 317 | 317 |
Useful for debugging. |
| 318 |
.It "\ \ " Em tabcomplete |
|
| 319 |
Enables filename completion in the command line editor. |
|
| 320 |
Typing a tab character will extend the current input word to match a |
|
| 321 |
filename. |
|
| 322 |
If more than one filename matches it is only extended to be the common prefix. |
|
| 323 |
Typing a second tab character will list all the matching names. |
|
| 324 |
Turned on by default in an interactive shell. |
|
| 318 | 325 |
.El |
| 319 | 326 |
.Pp |
| 320 | 327 |
The |
| ... | ... | |
| 2279 | 2286 |
The |
| 2280 | 2287 |
.Nm |
| 2281 | 2288 |
utility does not recognize multibyte characters. |
| 2289 |
.Pp |
|
| 2290 |
The characters generated by filename completion should probably be quoted |
|
| 2291 |
to ensure that the filename is still valid after the input line has been |
|
| 2292 |
processed. |
|
| 2282 |
- |
|