tags 694024 + patch thanks On Sun, 25 Nov 2012 17:06:46 +0100 Stefan Fritsch <s...@sfritsch.de> wrote:
> severity 694024 serious > thanks > > On Sunday 25 November 2012, Stefan Fritsch wrote: > > But I think zutils should be fixed instead to behave as the normal > > zgrep, especially since it adds a diversion for the normal zgrep. > > Actually, that's RC. zgrep is in gzip, which is Essential: yes. I attached a patch which does that: Description: Don’t print file name if only one file is grepped This patch makes zutils behave like grep(1) in that the default for grep_show_name is false when one file is being searched and true when multiple files are being searched. Of course, -h and -H overwrite the default. Reviews welcome. -- Best regards, Michael
Description: Donât print file name if only one file is grepped This patch makes zutils behave like grep(1) in that the default for grep_show_name is false when one file is being searched and true when multiple files are being searched. Of course, -h and -H overwrite the default. Author: Michael Stapelberg <stapelb...@debian.org> Bug-Debian: http://bugs.debian.org/694024 Forwarded: http://lists.nongnu.org/archive/html/zutils-bug/2012-12/threads.html Last-Update: 2012-12-04 --- zutils-0.9.orig/main.cc +++ zutils-0.9/main.cc @@ -245,6 +245,7 @@ int main( const int argc, const char * c int argind = 0; bool grep_list = false; bool grep_show_name = true; + bool grep_show_name_default = true; bool grep_pattern_found = false; for( ; argind < parser.arguments(); ++argind ) { @@ -302,8 +303,8 @@ int main( const int argc, const char * c case 'f': grep_args.push_back( "-f" ); grep_args.push_back( arg ); grep_pattern_found = true; break; case 'F': grep_args.push_back( "-F" ); break; - case 'h': grep_show_name = false; break; - case 'H': grep_show_name = true; break; + case 'h': grep_show_name = false; grep_show_name_default = false; break; + case 'H': grep_show_name = true; grep_show_name_default = false; break; case 'i': grep_args.push_back( "-i" ); break; case 'I': grep_args.push_back( "-I" ); break; case 'l': grep_args.push_back( "-l" ); grep_list = true; break; @@ -350,6 +351,11 @@ int main( const int argc, const char * c if( filenames.empty() ) filenames.push_back("-"); + if( grep_show_name_default && filenames.size() == 1 ) + { + grep_show_name = false; + } + int retval = ( ( program_mode == m_zgrep ) ? 1 : 0 ); while( !filenames.empty() ) {