Skip to content

Commit

Permalink
Make N at EOF do default print: Linux has never obeyed Posix here.
Browse files Browse the repository at this point in the history
Red Hat 9 circa 2003 treated EOF as a blank line, so added an extra EOF,
but that got fixed long ago, and now even preserves lack-of-newline ala
echo -n one | sed N
  • Loading branch information
landley committed Sep 13, 2022
1 parent 9c9d3fa commit 1724b35
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion toys/posix/sed.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* printf escapes in text, line continuations, semicolons after all commands,
* 2-address anywhere an address is allowed, "T" command, multiline
* continuations for [abc], \; to end [abc] argument before end of line.
* N at EOF does default print: posix says not to but Linux always has.
USE_SED(NEWTOY(sed, "(help)(version)e*f*i:;nErz(null-data)s[+Er]", TOYFLAG_BIN|TOYFLAG_LOCALE|TOYFLAG_NOHELP))
Expand Down Expand Up @@ -572,9 +573,9 @@ static void sed_line(char **pline, long plen)
command = command->next;
}

done:
if (line && !FLAG(n)) emit(line, len, eol);

done:
if (dlist_terminate(append)) while (append) {
struct append *a = append->next;

Expand Down

0 comments on commit 1724b35

Please sign in to comment.