@@ -3371,15 +3371,14 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
33713371 if (line.empty ())
33723372 return ;
33733373 }
3374- bool echoed_command = false ;
33753374 if (!is_interactive) {
33763375 // When using a non-interactive file handle (like when sourcing commands
33773376 // from a file) we need to echo the command out so we don't just see the
33783377 // command output and no command...
33793378 if (EchoCommandNonInteractive (line, io_handler.GetFlags ())) {
3380- io_handler. GetOutputStreamFileSP ()-> Lock ()
3381- << io_handler.GetPrompt () << line << ' \n ' ;
3382- echoed_command = true ;
3379+ LockedStreamFile locked_stream =
3380+ io_handler.GetOutputStreamFileSP ()-> Lock () ;
3381+ locked_stream. Printf ( " %s%s \n " , io_handler. GetPrompt (), line. c_str ()) ;
33833382 }
33843383 }
33853384
@@ -3399,21 +3398,10 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
33993398 lldb_private::CommandReturnObject result (m_debugger.GetUseColor ());
34003399 HandleCommand (line.c_str (), eLazyBoolCalculate, result);
34013400
3402- const bool print_result =
3403- result.Succeeded () &&
3404- io_handler.GetFlags ().Test (eHandleCommandFlagPrintResult);
3405- const bool print_error =
3406- io_handler.GetFlags ().Test (eHandleCommandFlagPrintErrors);
3407-
3408- // Now emit the command output text from the command we just executed.
3409- if (print_result || print_error) {
3410- // If the command failed and we didn't echo it, echo it now so the user
3411- // knows which command produced the error.
3412- if (!echoed_command && !result.Succeeded () && print_error) {
3413- io_handler.GetOutputStreamFileSP ()->Lock ()
3414- << io_handler.GetPrompt () << line << ' \n ' ;
3415- }
3416-
3401+ // Now emit the command output text from the command we just executed
3402+ if ((result.Succeeded () &&
3403+ io_handler.GetFlags ().Test (eHandleCommandFlagPrintResult)) ||
3404+ io_handler.GetFlags ().Test (eHandleCommandFlagPrintErrors)) {
34173405 auto DefaultPrintCallback = [&](const CommandReturnObject &result) {
34183406 // Display any inline diagnostics first.
34193407 const bool inline_diagnostics = !result.GetImmediateErrorStream () &&
0 commit comments