mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 09:27:00 +02:00
Shell: Read and evaluate an init file on start
This behaviour is overridable with the `--skip-init' flag. The default file is at '~/shell-init.sh'
This commit is contained in:
committed by
Andreas Kling
parent
3d6a035d0f
commit
bc3285abb0
Notes:
sideshowbarker
2024-07-19 05:09:30 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/bc3285abb02 Pull-request: https://github.com/SerenityOS/serenity/pull/2542 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bugaevc
@@ -460,6 +460,22 @@ RefPtr<Job> Shell::run_command(AST::Command& command)
|
||||
return *job;
|
||||
}
|
||||
|
||||
bool Shell::run_file(const String& filename)
|
||||
{
|
||||
auto file_result = Core::File::open(filename, Core::File::ReadOnly);
|
||||
if (file_result.is_error()) {
|
||||
fprintf(stderr, "Failed to open %s: %s\n", filename.characters(), file_result.error().characters());
|
||||
return false;
|
||||
}
|
||||
auto file = file_result.value();
|
||||
for (;;) {
|
||||
auto line = file->read_line(4096);
|
||||
if (line.is_null())
|
||||
break;
|
||||
run_command(String::copy(line, Chomp));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void Shell::take_back_stdin()
|
||||
{
|
||||
tcsetpgrp(0, m_pid);
|
||||
|
||||
Reference in New Issue
Block a user