1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

Shell: Do not treat the absence of an init script as an error

This commit is contained in:
AnotherTest 2020-07-05 19:27:37 +04:30 committed by Andreas Kling
parent e83c36d053
commit 6d17fe38a4
3 changed files with 6 additions and 5 deletions

View file

@ -499,10 +499,11 @@ RefPtr<Job> Shell::run_command(AST::Command& command)
return *job;
}
bool Shell::run_file(const String& filename)
bool Shell::run_file(const String& filename, bool explicitly_invoked)
{
auto file_result = Core::File::open(filename, Core::File::ReadOnly);
if (file_result.is_error()) {
if (explicitly_invoked)
fprintf(stderr, "Failed to open %s: %s\n", filename.characters(), file_result.error().characters());
return false;
}

View file

@ -73,7 +73,7 @@ public:
int run_command(const StringView&);
RefPtr<Job> run_command(AST::Command&);
bool run_file(const String&);
bool run_file(const String&, bool explicitly_invoked = true);
bool run_builtin(int argc, const char** argv, int& retval);
bool has_builtin(const StringView&) const;
void block_on_job(RefPtr<Job>);

View file

@ -146,8 +146,8 @@ int main(int argc, char** argv)
String file_path = Shell::init_file_path;
if (file_path.starts_with('~'))
file_path = shell->expand_tilde(file_path);
if (!shell->run_file(file_path)) {
fprintf(stderr, "Shell: Failed to execute init file '%s'\n", Shell::init_file_path);
if (Core::File::exists(file_path)) {
shell->run_file(file_path, false);
}
}