GNU bug report logs - #24532
GNU wc --lines doesn't report last line when that doesn't end on a new-line.

Previous Next

Package: coreutils;

Reported by: Carlo Wood <carlo <at> alinoe.com>

Date: Sun, 25 Sep 2016 00:12:03 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 24532-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Carlo Wood <carlo <at> alinoe.com>, 24532-done <at> debbugs.gnu.org
Subject: Re: bug#24532: GNU wc --lines doesn't report last line when that
 doesn't end on a new-line.
Date: Sat, 24 Sep 2016 19:00:12 -0700
Carlo Wood wrote:
> You can argue that this is a feature, but I consider it a bug for all
> practical purposes.

POSIX requires that wc -l must just count newlines, so it is indeed a feature.

If wc -l also counted incomplete lines at the end of a file, this would result 
in counterintuitive behavior of a different sort. For example:

cat a b >c
wc -l a
wc -l b
wc -l c

Currently the first two numbers must sum to the third, but that would not be 
true under the change you're proposing.

Incomplete lines must cause a problem of some sort, and I'm afraid that the 
longstanding tradition is to cause the problem you ran into.




This bug report was last modified 8 years and 237 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.