From 1724b3589a50b35b247707d6a093cdad4f9158a0 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 13 Sep 2022 07:03:43 -0500 Subject: [PATCH] Make N at EOF do default print: Linux has never obeyed Posix here. 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 --- toys/posix/sed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toys/posix/sed.c b/toys/posix/sed.c index cea12ea5..3b3e4c31 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -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)) @@ -572,9 +573,9 @@ writenow: command = command->next; } +done: if (line && !FLAG(n)) emit(line, len, eol); -done: if (dlist_terminate(append)) while (append) { struct append *a = append->next; -- 2.39.2