shell: Allow running as interactive even if not running in a TTY

This commit is contained in:
apio 2023-09-14 21:31:45 +02:00
parent bb5d726fe8
commit 0e8183d2bb
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -85,6 +85,7 @@ Result<int> luna_main(int argc, char** argv)
{
StringView path;
StringView command;
bool interactive { false };
SharedPtr<File> input_file;
@ -93,6 +94,7 @@ Result<int> luna_main(int argc, char** argv)
parser.add_system_program_info("sh"_sv);
parser.add_positional_argument(path, "path"_sv, "-"_sv);
parser.add_value_argument(command, 'c', "command"_sv, "execute a single command and then exit"_sv);
parser.add_switch_argument(interactive, 'i', "interactive"_sv, "run an interactive shell"_sv);
parser.parse(argc, argv);
// TODO: This does not properly handle builtins.
@ -105,7 +107,7 @@ Result<int> luna_main(int argc, char** argv)
input_file->set_close_on_exec();
}
bool interactive = isatty(input_file->fd());
if (isatty(input_file->fd())) interactive = true;
if (interactive)
{