54 lines
1.8 KiB
Diff
54 lines
1.8 KiB
Diff
Author: Antonio Diaz Diaz <ant_diaz@teleline.es>
|
|
Description:
|
|
Make 'grep_show_name' tri-state so that file name is no prefixed to output by
|
|
default when searching one file.
|
|
|
|
diff -Naurp zutils.orig/doc/zutils.info zutils/doc/zutils.info
|
|
--- zutils.orig/doc/zutils.info 2012-12-10 11:18:56.507741935 +0100
|
|
+++ zutils/doc/zutils.info 2012-12-10 11:21:49.519773976 +0100
|
|
@@ -389,7 +389,8 @@ matches were found, and 2 means trouble.
|
|
|
|
`-h'
|
|
`--no-filename'
|
|
- Suppress the prefixing filename on output.
|
|
+ Suppress the prefixing of filenames on output when multiple files
|
|
+ are searched.
|
|
|
|
`-H'
|
|
`--with-filename'
|
|
diff -Naurp zutils.orig/doc/zutils.texinfo zutils/doc/zutils.texinfo
|
|
--- zutils.orig/doc/zutils.texinfo 2012-12-10 11:18:56.507741935 +0100
|
|
+++ zutils/doc/zutils.texinfo 2012-12-10 11:21:49.519773976 +0100
|
|
@@ -432,7 +432,8 @@ Treat @var{pattern} as a set of newline-
|
|
|
|
@item -h
|
|
@itemx --no-filename
|
|
-Suppress the prefixing filename on output.
|
|
+Suppress the prefixing of filenames on output when multiple files are
|
|
+searched.
|
|
|
|
@item -H
|
|
@itemx --with-filename
|
|
diff -Naurp zutils.orig/main.cc zutils/main.cc
|
|
--- zutils.orig/main.cc 2012-12-10 11:18:56.507741935 +0100
|
|
+++ zutils/main.cc 2012-12-10 11:21:49.519773976 +0100
|
|
@@ -243,8 +243,8 @@ int main( const int argc, const char * c
|
|
return ( program_mode == m_zcat ) ? 1 : 2; }
|
|
|
|
int argind = 0;
|
|
+ int grep_show_name = -1;
|
|
bool grep_list = false;
|
|
- bool grep_show_name = true;
|
|
bool grep_pattern_found = false;
|
|
for( ; argind < parser.arguments(); ++argind )
|
|
{
|
|
@@ -350,6 +350,9 @@ int main( const int argc, const char * c
|
|
|
|
if( filenames.empty() ) filenames.push_back("-");
|
|
|
|
+ if( grep_show_name < 0 && filenames.size() == 1 )
|
|
+ grep_show_name = false;
|
|
+
|
|
int retval = ( ( program_mode == m_zgrep ) ? 1 : 0 );
|
|
while( !filenames.empty() )
|
|
{
|