Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot insert blank line in global insert mode #134

Open
mohd-akram opened this issue Jul 6, 2024 · 2 comments
Open

Cannot insert blank line in global insert mode #134

mohd-akram opened this issue Jul 6, 2024 · 2 comments

Comments

@mohd-akram
Copy link
Contributor

To reproduce:

$ cat file
enum
$ printf '%s\n' 'g/enum/i\' '\' '.' '%p' | nvi -e file

Expected output:


enum

Actual output:

enum

The correct behavior is observed in ed and classic vi/ex (tested on OpenIndiana 2024.04).

@lichray
Copy link
Owner

lichray commented Jul 9, 2024

The debugger leads me to

nvi2/ex/ex_append.c

Lines 110 to 147 in 52c07e8

/*
* !!!
* Anything that was left after the command separator becomes part
* of the inserted text. Apparently, it was common usage to enter:
*
* :g/pattern/append|stuff1
*
* and append the line of text "stuff1" to the lines containing the
* pattern. It was also historically legal to enter:
*
* :append|stuff1
* stuff2
* .
*
* and the text on the ex command line would be appended as well as
* the text inserted after it. There was an historic bug however,
* that the user had to enter *two* terminating lines (the '.' lines)
* to terminate text input mode, in this case. This whole thing
* could be taken too far, however. Entering:
*
* :append|stuff1\
* stuff2
* stuff3
* .
*
* i.e. mixing and matching the forms confused the historic vi, and,
* not only did it take two terminating lines to terminate text input
* mode, but the trailing backslashes were retained on the input. We
* match historic practice except that we discard the backslashes.
*
* Input lines specified on the ex command line lines are separated by
* <newline>s. If there is a trailing delimiter an empty line was
* inserted. There may also be a leading delimiter, which is ignored
* unless it's also a trailing delimiter. It is possible to encounter
* a termination line, i.e. a single '.', in a global command, but not
* necessary if the text insert command was the last of the global
* commands.
*/

Is this document relevant?

@mohd-akram
Copy link
Contributor Author

Yes, somewhat, I think this is just a bug. A possible fix is to just remove the if (t != p || len == 0) check (I suggested it to the nvi maintainers to validate it), but it seems correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants