diff --git a/main.cc b/main.cc index 9397965..d2e623e 100644 --- a/main.cc +++ b/main.cc @@ -202,13 +202,14 @@ bool check_files( const char * const iname, const char * const oname, } if( check_identical( iname, oname ) ) { show_error( "Infile and outfile are the same." ); return false; } - if( !force || preallocate ) + bool nulldev = !std::strcmp( oname, "/dev/null" ); + if( !(force || nulldev) || preallocate ) { struct stat st; if( stat( oname, &st ) == 0 && !S_ISREG( st.st_mode ) ) { show_error( "Output file exists and is not a regular file." ); - if( !force ) + if( !(force || nulldev) ) { show_error( "Use `--force' if you really want to overwrite it, but be" ); show_error( "aware that all existing data in output file will be lost.", 0, true );