Public bug reported:

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).

** Affects: grep (Ubuntu)
     Importance: Undecided
         Status: New

-- 
--label should be used with -H too
https://bugs.launchpad.net/bugs/264448
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to