bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24961: input option -z alters behavior of output option -o in an und


From: vampyrebat
Subject: bug#24961: input option -z alters behavior of output option -o in an undocumented way
Date: Fri, 18 Nov 2016 00:16:19 -0600

This bug report concerns GNU grep 2.25.

Consider this file:

$ cat test
one lone
long
tone

"grep -o", according to the man page and info file, outputs "each [matched] 
part on a separate output line."  Given that, this command gives the expected 
output:

$ grep -o one test
one
one
one

The documentation also states that -z affects only how input is interpreted.  
However, adding -z makes -o no longer obey the above-quoted documentation line:

$ grep -zo one test
oneoneone

Hexdump shows that this output has ASCII NULs in place of newlines:

$ grep -zo one test | hexdump -C
00000000  6f 6e 65 00 6f 6e 65 00  6f 6e 65 00              |one.one.one.|
0000000c

Thus, -z changes the line separator used by -o.  This might or might not be 
desired behavior, but it is certainly not behavior that the documentation leads 
one to expect.  In other words, I don't know whether this is a software bug or 
a documentation bug, only that the two don't agree.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]