Skip to content

Commit

Permalink
Shell: Disable interactive mode on '-c'
Browse files Browse the repository at this point in the history
This also disables the full suite of interactive stuff in LibLine.
  • Loading branch information
alimpfard authored and linusg committed Dec 12, 2022
1 parent 3fccf24 commit 4311c21
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Userland/Shell/main.cpp
Expand Up @@ -47,7 +47,15 @@ ErrorOr<int> 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);
Expand Down Expand Up @@ -199,7 +207,7 @@ ErrorOr<int> 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.");
Expand Down

0 comments on commit 4311c21

Please sign in to comment.