[BusyBox] cut bug

Mark Whitley markw at lineo.com
Fri Nov 17 20:25:28 UTC 2000


On Fri, Nov 17, 2000 at 02:02:31PM -0600, BRENT PRIDDY wrote:

[Re: test case]

> haha, yep that would be helpful...
> 
> stupid me
> 
> file.txt
> <snip>
> one line
> second line
> third line
> </snip>
> 
> and do the following command
> 
> cat file.txt | cut -f 2 -d '
> '
> 
> (note that i entered a \n in-between the ''s)
> 
> you should only get "second line"
> 
> this works with gnu 2.0 cut

Ah ha, thanks for the test case; it clarifies the problem for me.

With your patch applied, I tried your test case and it worked for me. However,
I then tried a test file like this:

---begin tstcut.txt--------
one line
second line
third line
fourth line
fifth line
sixth line
seventh line
eighth line
---end tstcut.txt--------

And tried doing this, with the following output:


cat tstcut.txt | ./busybox cut -f 2-5 -d '
'
second line


GNU cut produces this output:


cat tstcut.txt | cut -f 2-5 -d '
'
second line
third line
fourth line
fifth line


Whoops.

I can see where the problem is: your conditional block that handles the
special-case of a newline doesn't keep reading from the input file. I can
probably take a minute to work on it and get it in shape, unless you'd like to
tackle it. Your call.

Mark Whitley
markw at lineo.com





More information about the busybox mailing list