diff --git a/Base/home/anon/shell-init.sh b/Base/home/anon/.shellrc similarity index 100% rename from Base/home/anon/shell-init.sh rename to Base/home/anon/.shellrc diff --git a/Shell/Shell.h b/Shell/Shell.h index 1b95118b2e..0d6d1193dc 100644 --- a/Shell/Shell.h +++ b/Shell/Shell.h @@ -69,7 +69,8 @@ class Shell : public Core::Object { C_OBJECT(Shell); public: - constexpr static auto init_file_path = "~/shell-init.sh"; + constexpr static auto local_init_file_path = "~/.shellrc"; + constexpr static auto global_init_file_path = "/etc/shellrc"; bool is_accepting_signals() const { return m_is_accepting_signals; } diff --git a/Shell/main.cpp b/Shell/main.cpp index d08994c3a6..977e9988ad 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -150,22 +150,26 @@ int main(int argc, char** argv) const char* command_to_run = nullptr; const char* file_to_read_from = nullptr; - bool skip_init_file = false; + bool skip_rc_files = false; Core::ArgsParser parser; parser.add_option(command_to_run, "String to read commands from", "command-string", 'c', "command-string"); parser.add_positional_argument(file_to_read_from, "File to read commands from", "file", Core::ArgsParser::Required::No); - parser.add_option(skip_init_file, "Skip running ~/shell-init.sh", "skip-init", 0); + parser.add_option(skip_rc_files, "Skip running shellrc files", "skip-shellrc", 0); parser.parse(argc, argv); - if (!skip_init_file) { - String file_path = Shell::init_file_path; - if (file_path.starts_with('~')) - file_path = shell->expand_tilde(file_path); - if (Core::File::exists(file_path)) { - shell->run_file(file_path, false); - } + if (!skip_rc_files) { + auto run_rc_file = [&](auto& name) { + String file_path = name; + if (file_path.starts_with('~')) + file_path = shell->expand_tilde(file_path); + if (Core::File::exists(file_path)) { + shell->run_file(file_path, false); + } + }; + run_rc_file(Shell::global_init_file_path); + run_rc_file(Shell::local_init_file_path); } if (command_to_run) {