[BusyBox] [PATCH] grep -h bug
Pauli Saksa
psaksa at cc.hut.fi
Thu Oct 14 09:51:26 UTC 2004
Greetings,
grep's -h option (suppress filename prefix) seems to do exactly the opposite
with only one input file.
> ./busybox grep -h hexdump busybox.links busybox.links
/usr/bin/hexdump
/usr/bin/hexdump
> ./busybox grep -h hexdump busybox.links
busybox.links:/usr/bin/hexdump
GNU grep does not invert the operation:
> grep -h hexdump busybox.links busybox.links
/usr/bin/hexdump
/usr/bin/hexdump
> grep -h hexdump busybox.links
/usr/bin/hexdump
Following patch should fix this. I just noticed this in 1.00-pre3, but it seems
to be in 1.00 as well. The patch is to version 1.00. Thanks.
--
Pauli Saksa
psaksa at cc.hut.fi
--------------------------------------------------
--- busybox-1.00.orig/findutils/grep.c 2004-10-08 11:10:57.000000000 +0300
+++ busybox-1.00/findutils/grep.c 2004-10-14 12:04:14.000000000 +0300
@@ -98,7 +98,7 @@
}
last_line_printed = linenum;
#endif
- if (print_filename)
+ if (print_filename>0)
printf("%s%c", cur_file, decoration);
if (print_line_num)
printf("%i%c", linenum, decoration);
@@ -219,7 +219,7 @@
/* grep -c: print [filename:]count, even if count is zero */
if (print_match_counts) {
- if (print_filename)
+ if (print_filename>0)
printf("%s:", cur_file);
printf("%d\n", nmatches);
}
--------------------------------------------------
More information about the busybox
mailing list