From 7c7061f7713e47b435ce1924b225fb64d1ae56d5 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 2 Jun 2013 18:51:16 +0100 Subject: rev: stop adding new line at the end when input does not have it When the rev(1) is executed twice outcome is expected to be exactly what it was originally. That includes not adding new line at the end of the output. The oneliner below demonstrates earlier issue. $ printf "abc\n123" | rev | rev Signed-off-by: Sami Kerola --- text-utils/rev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'text-utils/rev.c') diff --git a/text-utils/rev.c b/text-utils/rev.c index 95545064a..0456c2b14 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -159,7 +159,8 @@ int main(int argc, char *argv[]) if (*t != 0) putwchar(*t); } - putwchar('\n'); + if (!feof(fp)) + putwchar('\n'); } fflush(fp); -- cgit v1.2.3-55-g7522