On 19 Oct 08:49, Klemens Nanni wrote:
> On Wed, Aug 31, 2022 at 05:16:27PM +0200, Uwe Werler wrote:
> > Hi folks,
> > 
> > I'm just wondering why there's a test for an empty line and args to start 
> > the
> > editor for line editing. In bash one can start vi immediately with an empty
> > line by ^v. Might be there's another reason I don't understand for this 
> > test?
> 
> Logically, this should probably be allowed, but reading ksh(1)
> 
>      [n]v        Edit line n using the vi(1) editor; if n is not specified,
>                  the current line is edited.  The actual command executed is
>                  fc -e ${VISUAL:-${EDITOR:-vi}} n.
> 
> this says that editing is implemented via history
> 
>      fc [-e editor | -l [-n]] [-r] [first [last]]
>                   Fix command.  first and last select commands from the 
> history.
>                   Commands can be selected by history number or a string 
> specifying
>                   the most recent command starting with that string.  The -l 
> option
>                   lists the command on standard output, and -n inhibits the 
> default
>                   command numbers.  The -r option reverses the order of the 
> list.
>                   Without -l, the selected commands are edited by the editor
>                   specified with the -e option, or if no -e is specified, the
>                   editor specified by the FCEDIT parameter (if this parameter 
> is
>                   not set, /bin/ed is used), and then executed by the shell.
> 
> ^v does not specify a number, so ksh supposedly runs `fc -e vi'?
> 
> The `fc' synopsis does not show how to use "a string specifying the most
> recent command starting with that string...
> 
> I guess ^v uses the current line for this string (no idea how), at which
> point it makes sense to not pass the empty string.
> 
> In vi mode, if you enter only spaces, then ESC then `v' to edit:
> - our ksh will edit the previous line, not current whitespace one
> - ksh93 from ports will print a warning and not do anything
> 
> 
> So without looking at the code, I think this check is warranted.

Just for the record because first I thought the diff caused the empty lines in
my history file:

1. run some command
2. enter a blank and hit ^v so the last run command will be in the editor
3. delete the line and leave
4. check with fc -l

An empty line is then stored to the history.

-- 
wq: ~uw

Reply via email to