summaryrefslogtreecommitdiffstats
path: root/main.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:45:50 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:45:50 +0000
commit0763626b1d5a396a8d78985c9a445763686f92f8 (patch)
tree128aaf42cc9d59adf31b97b65788a0b56acb8da3 /main.cc
parentAdding debian version 1.16~pre1-1. (diff)
downloadlziprecover-0763626b1d5a396a8d78985c9a445763686f92f8.tar.xz
lziprecover-0763626b1d5a396a8d78985c9a445763686f92f8.zip
Merging upstream version 1.16~pre2.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--main.cc21
1 files changed, 9 insertions, 12 deletions
diff --git a/main.cc b/main.cc
index e5b1cbc..81a13aa 100644
--- a/main.cc
+++ b/main.cc
@@ -256,17 +256,6 @@ bool open_outstream( const bool force )
}
-bool check_tty( const int infd )
- {
- if( isatty( infd ) )
- {
- show_error( "I won't read compressed data from a terminal.", 0, true );
- return false;
- }
- return true;
- }
-
-
void cleanup_and_fail( const int retval )
{
if( delete_output_on_interrupt )
@@ -591,6 +580,7 @@ int main( const int argc, const char * const argv[] )
if( filenames.back() != "-" ) filenames_given = true;
}
+ try {
switch( program_mode )
{
case m_none: internal_error( "invalid operation." ); break;
@@ -620,6 +610,9 @@ int main( const int argc, const char * const argv[] )
return split_file( filenames[0], default_output_filename, verbosity, force );
case m_test: break;
}
+ }
+ catch( std::bad_alloc ) { show_error( "Not enough memory." ); return 1; }
+ catch( Error e ) { show_error( e.msg, errno ); return 1; }
if( program_mode == m_test )
outfd = -1;
@@ -683,7 +676,11 @@ int main( const int argc, const char * const argv[] )
}
}
- if( !check_tty( infd ) ) return 1;
+ if( isatty( infd ) )
+ {
+ show_error( "I won't read compressed data from a terminal.", 0, true );
+ return 1;
+ }
if( output_filename.size() && !to_stdout && program_mode != m_test )
delete_output_on_interrupt = true;