shell: Allow running as interactive even if not running in a TTY
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
dce7b92c95
commit
8227e7c0ea
@ -85,6 +85,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
StringView path;
|
StringView path;
|
||||||
StringView command;
|
StringView command;
|
||||||
|
bool interactive { false };
|
||||||
|
|
||||||
SharedPtr<File> input_file;
|
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_system_program_info("sh"_sv);
|
||||||
parser.add_positional_argument(path, "path"_sv, "-"_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_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);
|
parser.parse(argc, argv);
|
||||||
|
|
||||||
// TODO: This does not properly handle builtins.
|
// 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();
|
input_file->set_close_on_exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool interactive = isatty(input_file->fd());
|
if (isatty(input_file->fd())) interactive = true;
|
||||||
|
|
||||||
if (interactive)
|
if (interactive)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user