]> git.lizzy.rs Git - plan9front.git/commitdiff
grep: fix handling of -b flag
authorAlex Musolino <alex@musolino.id.au>
Thu, 26 Mar 2020 07:54:39 +0000 (18:24 +1030)
committerAlex Musolino <alex@musolino.id.au>
Thu, 26 Mar 2020 07:54:39 +0000 (18:24 +1030)
Output buffering is automatically disabled when reading from stdin.
In this case, supplying the -b flag ought to be redundant.  However,
since Bflag was being XORed into the flag set - rather than simply
ORed - supplying -b would actually enable output buffering.

sys/src/cmd/grep/main.c

index d17be9c590fd5edf431dd9223ab63518ea34d1e3..9ef2ba6e8fb79b97ba6478686f1604e69623ce63 100644 (file)
@@ -91,7 +91,7 @@ search(char *file, int flag)
        }
 
        if(flags['b'])
-               flag ^= Bflag;          /* dont buffer output */
+               flag |= Bflag;          /* dont buffer output */
        if(flags['c'])
                flag |= Cflag;          /* count */
        if(flags['h'])