From 4311c2164e60e2765e1f50e065c627d678635f3d Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 12 Dec 2022 14:34:09 +0330 Subject: [PATCH] Shell: Disable interactive mode on '-c' This also disables the full suite of interactive stuff in LibLine. --- Userland/Shell/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 6214ea8f6d..5512d2240f 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -47,7 +47,15 @@ ErrorOr serenity_main(Main::Arguments arguments) bool attempt_interactive = false; auto initialize = [&] { - editor = Line::Editor::construct(); + auto configuration = Line::Configuration::from_config(); + if (!attempt_interactive) { + configuration.set(Line::Configuration::Flags::None); + configuration.set(Line::Configuration::SignalHandler::NoSignalHandlers); + configuration.set(Line::Configuration::OperationMode::NonInteractive); + configuration.set(Line::Configuration::RefreshBehavior::Eager); + } + + editor = Line::Editor::construct(move(configuration)); editor->initialize(); shell = Shell::Shell::construct(*editor, attempt_interactive); @@ -199,7 +207,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto execute_file = !file_to_read_from.is_empty() && "-"sv != file_to_read_from; - attempt_interactive = !execute_file; + attempt_interactive = !execute_file && (command_to_run.is_empty() || keep_open); if (keep_open && command_to_run.is_empty() && !execute_file) { warnln("Option --keep-open can only be used in combination with -c or when specifying a file to execute.");