summaryrefslogtreecommitdiffstats
path: root/zcat.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-05-20 06:48:30 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-05-20 06:49:00 +0000
commit4d364776fc785a234cebba08bc93cd06202103dd (patch)
tree90476b30bb959b780c85efc2ab546a5b5e970f2c /zcat.cc
parentReleasing debian version 1.4-2. (diff)
downloadzutils-4d364776fc785a234cebba08bc93cd06202103dd.tar.xz
zutils-4d364776fc785a234cebba08bc93cd06202103dd.zip
Merging upstream version 1.5.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zcat.cc')
-rw-r--r--zcat.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/zcat.cc b/zcat.cc
index e4f7956..98081c3 100644
--- a/zcat.cc
+++ b/zcat.cc
@@ -1,5 +1,5 @@
/* Zcat - decompress and concatenate files to standard output
- Copyright (C) 2010-2015 Antonio Diaz Diaz.
+ Copyright (C) 2010-2016 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -90,14 +90,14 @@ Line_number line_number;
void show_help()
{
- std::printf( "Zcat copies each given file (\"-\" means standard input), to standard\n"
- "output. If any given file is compressed, its decompressed content is\n"
- "used. If a given file does not exist, and its name does not end with one\n"
- "of the known extensions, zcat tries the compressed file names\n"
- "corresponding to the supported formats. If no files are specified,\n"
- "data is read from standard input, decompressed if needed, and sent to\n"
- "standard output. Data read from standard input must be of the same type;\n"
- "all uncompressed or all in the same compression format.\n"
+ std::printf( "Zcat copies each given file to standard output. If any given file is\n"
+ "compressed, its decompressed content is used. If a given file does not\n"
+ "exist, and its name does not end with one of the known extensions, zcat\n"
+ "tries the compressed file names corresponding to the supported formats.\n"
+ "\nIf no files are specified, or if a file is specified as '-', data is\n"
+ "read from standard input, decompressed if needed, and sent to standard\n"
+ "output. Data read from standard input must be of the same type; all\n"
+ "uncompressed or all in the same compression format.\n"
"\nThe supported formats are bzip2, gzip, lzip and xz.\n"
"\nUsage: zcat [options] [files]\n"
"\nExit status is 0 if no errors occurred, non-zero otherwise.\n"
@@ -346,13 +346,18 @@ int main( const int argc, const char * const argv[] )
for( ; argind < parser.arguments(); ++argind )
filenames.push_back( parser.argument( argind ) );
- if( filenames.empty() ) filenames.push_back("-");
+ if( filenames.empty() ) filenames.push_back( "-" );
int retval = 0;
bool error = false;
+ bool stdin_used = false;
while( next_filename( filenames, input_filename, error, recursive ) )
{
- if( input_filename.empty() ) infd = STDIN_FILENO;
+ if( input_filename.empty() )
+ {
+ if( stdin_used ) continue; else stdin_used = true;
+ infd = STDIN_FILENO;
+ }
else
{
infd = open_instream( input_filename, format_index < 0 );