[Bug 264448] Re: --label should be used with -H too
Ma Xiaojun
damage3025 at gmail.com
Thu Jun 6 13:54:29 UTC 2013
I guess it is already fixed in 12.04+ (EOL versions ignored)
http://manpages.ubuntu.com/manpages/precise/en/man1/grep.1.html
Correct me if I'm wrong.
** Changed in: grep (Ubuntu)
Status: New => Fix Released
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grep in Ubuntu.
https://bugs.launchpad.net/bugs/264448
Title:
--label should be used with -H too
Status in “grep” package in Ubuntu:
Fix Released
Bug description:
Binary package hint: grep
(Originally reported by Mike Bianchi via Landscape)
The grep manpage has an example about --label that doesn't work:
gzip -cd foo.gz | grep --label=foo something
The above command does not show the "foo" label as expected because
only one "file" (in this case, stdin) is being grepped.
In order for it to work, -H (Print the file name for each match) needs
to be added or else the label will not be printed.
This can be solved by:
a) patching grep.c so it automatically adds -H whenever --label is used. This would make the manpage correct. Something like this:
diff -uNr grep-2.5.3.orig/src/grep.c grep-2.5.3/src/grep.c
--- grep-2.5.3.orig/src/grep.c 2007-06-28 15:57:19.000000000 -0300
+++ grep-2.5.3/src/grep.c 2008-09-02 17:51:45.000000000 -0300
@@ -2137,6 +2137,7 @@
case LABEL_OPTION:
label = optarg;
+ with_filenames = 1;
break;
case 0:
b) patching the manpage to fix the example and mention that -H needs to be added. Something like this:
"--label does not imply -H. If the standard input is the only file
read (with either no argument or the - argument) and you want
matches marked with the --label value, add -H."
c) do both, i.e., apply the patch and mention in the manpage that -H
is implied whenever using --label.
The less impacting change would probably be (b).
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grep/+bug/264448/+subscriptions
More information about the foundations-bugs
mailing list