diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index dad6e5b12..841d52969 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -201,12 +201,29 @@ System::runCommand( System::RunLocation location, } auto r = process.exitCode(); - cDebug() << Logger::SubEntry << "Finished. Exit code:" << r; bool showDebug = ( !Calamares::Settings::instance() ) || ( Calamares::Settings::instance()->debugMode() ); - if ( ( r != 0 ) || showDebug ) + if ( r == 0 ) { - cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "output:\n" - << Logger::NoQuote {} << output; + if ( showDebug && !output.isEmpty() ) + { + cDebug() << Logger::SubEntry << "Finished. Exit code:" << r << "output:\n" << Logger::NoQuote {} << output; + } + else + { + cDebug() << Logger::SubEntry << "Finished. Exit code:" << r; + } + } + else // if ( r != 0 ) + { + if ( !output.isEmpty() ) + { + cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "Exit code:" << r << "output:\n" + << Logger::NoQuote {} << output; + } + else + { + cDebug() << Logger::SubEntry << "Target cmd:" << RedactedList( args ) << "Exit code:" << r << "(no output)"; + } } return ProcessResult( r, output ); }