bsd-grep-20080725_1 -v flag busted...

Chuck Swiger cswiger at mac.com
Mon Aug 4 20:32:11 UTC 2008


On Aug 4, 2008, at 1:18 PM, Andrey Chernov wrote:
>> echo 'fee\nfi\nfoe\nfum' | ./grep -v fi
>> echo 'fee\nfi\nfoe\nfum' | /usr/bin/grep -v fi
>
> Example is broken, echo (for sh) supposed to be
>
> echo 'fee
> fi
> foe
> fum' | ...

Well, if your shell's built-in echo doesn't grok newlines, then /usr/ 
bin/printf works, as Daniel suggested.  But using /bin/sh and a  
multiline statement as you suggest shows the exact same problem:

% echo 'fee
 > fi
 > foe
 > fum' | ./grep -v fi
% echo 'fee
 > fi
 > foe
 > fum' | /usr/bin/grep -v fi
fee
foe
fum

(I'm much more interested in confirming whether the bug I see in BSD  
grep is reproducible by others than debating how to get real newlines  
from various shells.)

-- 
-Chuck



More information about the freebsd-ports mailing list