summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-07-05 19:27:37 +0430
committerAndreas Kling <kling@serenityos.org>2020-07-06 13:25:42 +0200
commit6d17fe38a41354fec933574081c9b9a12c767f23 (patch)
tree65bee4f577089e56ca01010da05ea24364ad085f
parente83c36d053c302771f8fd781693ceaafa75e758d (diff)
downloadserenity-6d17fe38a41354fec933574081c9b9a12c767f23.zip
Shell: Do not treat the absence of an init script as an error
-rw-r--r--Shell/Shell.cpp5
-rw-r--r--Shell/Shell.h2
-rw-r--r--Shell/main.cpp4
3 files changed, 6 insertions, 5 deletions
diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp
index 063d335725..8b00e04f25 100644
--- a/Shell/Shell.cpp
+++ b/Shell/Shell.cpp
@@ -499,11 +499,12 @@ 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()) {
- fprintf(stderr, "Failed to open %s: %s\n", filename.characters(), file_result.error().characters());
+ if (explicitly_invoked)
+ fprintf(stderr, "Failed to open %s: %s\n", filename.characters(), file_result.error().characters());
return false;
}
auto file = file_result.value();
diff --git a/Shell/Shell.h b/Shell/Shell.h
index 5e9afbb968..dba1525e0e 100644
--- a/Shell/Shell.h
+++ b/Shell/Shell.h
@@ -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>);
diff --git a/Shell/main.cpp b/Shell/main.cpp
index bf98f0e720..743bab0d4d 100644
--- a/Shell/main.cpp
+++ b/Shell/main.cpp
@@ -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);
}
}