diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index 6ccba23bc..4e18aa0f1 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -1001,8 +1001,19 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) /* FALLTHROUGH */ case '*': /* filename expansion */ case '=': /* escape = - list all matching file names */ + { + char allempty = 1; + int x; ep->mark = cur; - if(cur<1) + for(x=0; x < cur; x++) + { + if(!isspace(out[x])) + { + allempty = 0; + break; + } + } + if(cur<1 || allempty) { beep(); return(-1); @@ -1040,6 +1051,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) draw(ep,UPDATE); } return(-1); + } /* search back for character */ case cntl(']'): /* feature not in book */ diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index c8bc5eab6..d491b084b 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -1537,6 +1537,22 @@ static void getline(register Vi_t* vp,register int mode) return; case '\t': /** command completion **/ + { + char allempty = 1; + int x; + for(x=0; x <= cur_virt; x++) + { + if(!isspace(virtual[x])) + { + allempty = 0; + break; + } + } + if(allempty) + { + ed_ringbell(); + break; + } if(sh_isoption(SH_VI) && mode != SEARCH && last_virt >= 0 && @@ -1566,6 +1582,7 @@ static void getline(register Vi_t* vp,register int mode) break; } /* FALLTHROUGH */ + } default: fallback: if( mode == REPLACE ) @@ -2545,7 +2562,18 @@ addin: case '*': /** do file name expansion in place **/ case '\\': /** do file name completion in place **/ case '=': /** list file name expansions **/ - if( cur_virt == INVALID ) + { + char allempty = 1; + int x; + for(x=0; x <= cur_virt; x++) + { + if(!isspace(virtual[x])) + { + allempty = 0; + break; + } + } + if(cur_virt == INVALID || allempty) return(BAD); /* FALLTHROUGH */ save_v(vp); @@ -2584,6 +2612,7 @@ addin: return(APPEND); } break; + } case '@': /** macro expansion **/ if( mode ) diff --git a/src/cmd/ksh93/sh.1 b/src/cmd/ksh93/sh.1 index fcccc4936..b01001f89 100644 --- a/src/cmd/ksh93/sh.1 +++ b/src/cmd/ksh93/sh.1 @@ -4987,6 +4987,8 @@ will provide a numbered list of matching alternatives. A specific selection can be made by entering the selection number followed by a .IR tab . +Neither completion nor listing operations are attempted before +the first character in a line. .SS Key Bindings. The .B @@ -5581,10 +5583,9 @@ or character. .TP 10 .BI ^I " tab" -Except at the start of the line, attempts command or -file name completion as described above and returns to -input mode. If a partial completion occurs, repeating -this will behave as if +Attempts command or file name completion as described +above and returns to input mode. If a partial completion +occurs, repeating this will behave as if .B = were entered from control mode. If no match is found or entered after