summaryrefslogtreecommitdiffstats
path: root/main.cc
diff options
context:
space:
mode:
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;