Re: ksh: allow editing empty line with 'v' in vi-mode

Johannes Thyssen Tishman <[email protected]> Fri, 31 Jul 2026 09:26:12 +0000
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
2026-07-30T16:42:22-0600 Andy Bradford <[email protected]>:
> Thus said Johannes Thyssen Tishman on Thu, 30 Jul 2026 18:21:29 -0000:
> 
> > -			if (es->linelen == 0 && argcnt == 0)
> > -				return -1;
> 
> These lines were last changed to correct a bug:
> 
> http://cvsweb.openbsd.org/log/src/bin/ksh/vi.c,v?sort=File#rev1.19
> 
> I'm not  sure what that bug  was, but I'm  not sure removing this  is an
> improvement.

The bug was that the history command number (n) in ^[nv was ignored
because empty lines were not allowed. The bug would've also been fixed
by removing the conditional (allowing then empty lines as well of
course).

> Also, you don't have to type nonsense to get into vi-mode, you just type
> a space and press esc-v. Doing so enters vi-mode with an empty buffer.

This is only possible if HISTCONTROL doesn't include 'ignorespace' (see
my reply to Uwe). While I could simply remove that option and do as you
suggest, I think that allowing ^[v in empty lines *and* ignoring
white-space only commands is a valid use case.