col: avoid extra newline if no input
BSD fix missed for 22 years, and all util-linux releases so far.
Backported-from: 2a15260a2a
Addresses: https://github.com/karelzak/util-linux/issues/422
Reported-by: Pavel Raiskup <praiskup@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
c6b0cbdd95
commit
b6b5272b03
|
@ -391,6 +391,8 @@ int main(int argc, char **argv)
|
||||||
/* goto the last line that had a character on it */
|
/* goto the last line that had a character on it */
|
||||||
for (; l->l_next; l = l->l_next)
|
for (; l->l_next; l = l->l_next)
|
||||||
this_line++;
|
this_line++;
|
||||||
|
if (max_line == 0)
|
||||||
|
return EXIT_SUCCESS; /* no lines, so just exit */
|
||||||
flush_lines(this_line - nflushd_lines + extra_lines + 1);
|
flush_lines(this_line - nflushd_lines + extra_lines + 1);
|
||||||
|
|
||||||
/* make sure we leave things in a sane state */
|
/* make sure we leave things in a sane state */
|
||||||
|
|
Loading…
Reference in New Issue