shithub: riscv

Download patch

ref: 47e3c088c90944e49041c8b210dd7169479738da
parent: 2f67e21393c25943f25e116fa6912b7d92dbca4e
author: Alex Musolino <[email protected]>
date: Thu Mar 26 14:24:39 EDT 2020

grep: fix handling of -b flag

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.

--- a/sys/src/cmd/grep/main.c
+++ b/sys/src/cmd/grep/main.c
@@ -91,7 +91,7 @@
 	}
 
 	if(flags['b'])
-		flag ^= Bflag;		/* dont buffer output */
+		flag |= Bflag;		/* dont buffer output */
 	if(flags['c'])
 		flag |= Cflag;		/* count */
 	if(flags['h'])