Missing newline in cut from textutils-2.1

Scott Herod <[email protected]> Mon, 11 Nov 2002 12:49:56 -0700 (MST)
Newsgroups gmane.comp.gnu.textutils.bugs
Message-ID <Pine.GSU.4.44.0211111027280.21604-100000@flatland.dimensional.com>
Hello,

I noticed that the cut utility does not put a trailing newline on lines
when delimiter cutting from stdin is used.  As an example of this:

bash> cut -f 1,3 -d ","
a,b,c,d,e
a,c

The results are correct in that "a,c" is returned, but there is no
trailing newline.  This differs from the behavior if character or byte
cutting is selected:

bash> cut -c 1,3
a,b,c,d,e
ab

Here the line "ab" has a trailing newline.

I believe that the problem is with the while 'if' statement that begins on
line 523:

      if (c == '\n')
	{
	  c = getc (stream);
	  if (c != EOF)
	    {
	      ungetc (c, stream);
	      c = '\n';
	    }
	}

The getc on the third line blocks until new data is entered so that the
putchar('\n') a few lines further down is not reached.

I'm not sure of a clean fix at this point but will continue to look at it.

Thank you,

Scott Herod
[email protected]