diff --git a/NEWS b/NEWS index 6d4aa366f..14e58d54a 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,21 @@ Any uppercase BUG_* names are modernish shell bug IDs. 2020-06-08: + - Fix an issue with the up arrow key in Emacs editing mode. + Emacs editing mode is bugged in ksh93u+ and ksh2020. Let's + say you were to run the following commands after starting + a fresh instance of ksh: + $ alias foo='true' + $ unalias foo + If you type 'a' and then press the up arrow on your keyboard, + ksh will complete 'a' to `alias foo='true'` by doing a reverse + search for the last command that starts with 'a'. + Run the alias command again, then type 'u' and press the up + arrow key again. If ksh is in Vi mode, you will get `unalias foo`, + but in Emacs mode you will get `alias foo='true'` again. + All subsequent commands were ignored as ksh was saving the first + command and only based later searches off of it. + - If 'set -u'/'set -o nounset' is active, then the shell now errors out if a nonexistent positional parameter such as $1, $2, ... is accessed, as other shells do and POSIX requires. (This does *not* apply to "$@" and "$*".) diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index 174b47761..87def4a57 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -1073,7 +1073,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) if(cur>0 && eol==cur && (cur<(SEARCHSIZE-2) || ep->prevdirection == -2)) #endif /* SHOPT_EDPREDICT */ { - if(ep->lastdraw==APPEND && ep->prevdirection != -2) + if(ep->lastdraw==APPEND) { out[cur] = 0; gencpy((genchar*)lstring+1,out);