[Bug 270048] nvi(1) errors when g//!{cmd} modifies the number of lines

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 08 Mar 2023 20:49:02 UTC

            Bug ID: 270048
           Summary: nvi(1) errors when g//!{cmd} modifies the number of
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: freebsd@tim.thechases.com

To replicate

 $ yes hello | head -50 | fmt -100 > wide_lines.txt
 $ vi wide_lines.txt

correctly formats the first line as expected.  However attempting 
to reformat each individual line with:


errors with """
Illegal address: only 6 lines in the file.
Error: unable to retrieve line 7; 4 lines added; 2 lines deleted
Press any key to continue: 

(the "4 lines added; 2 lines deleted" and possibly the "Press any 
key to continue" might be a screen artifact from prior to the error
message since it's not in reverse video like the rest of the error)

Expected behavior:  each individual line gets passed through fmt(1) 
to reformat it.

Observed behavior:  an error about the number of lines in the file
and only a portion of the lines are properly reformatted.

It sounds like something isn't re-calculating the number of lines 
in the file before/after a "!{cmd}" invocation within the context 
of a :g// command.  Or perhaps the lines marked by the g:// don't 
get updated after reading data output of an external "!{cmd}"

FWIW, this manifests in OpenBSD's nvi(1), too.

(bug encountered when using composing a mail message, wanting to reformat long
lines individually rather than by paragraph)

You are receiving this mail because:
You are the assignee for the bug.