From 52f56e2119c41864054c211350cef6dd8299d8a4 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 15 Feb 2021 20:57:11 +0100 Subject: [PATCH] WIP Add no-config mode This loads *no* config, *at all*. Not even share/config.fish, so $fish_function_path is entirely unset. --- src/fish.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/fish.cpp b/src/fish.cpp index 91b68f4e9..171ad6309 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -74,6 +74,8 @@ class fish_cmd_opts_t { std::vector postconfig_cmds; /// Whether to print rusage-self stats after execution. bool print_rusage_self{false}; + /// Whether no-config is set. + bool no_config{false}; /// Whether no-exec is set. bool no_exec{false}; /// Whether this is a login shell. @@ -261,7 +263,7 @@ static int run_command_list(parser_t &parser, std::vector *cmds, /// Parse the argument list, return the index of the first non-flag arguments. static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) { - static const char *const short_opts = "+hPilnvc:C:p:d:f:D:o:"; + static const char *const short_opts = "+hPilNnvc:C:p:d:f:D:o:"; static const struct option long_opts[] = { {"command", required_argument, nullptr, 'c'}, {"init-command", required_argument, nullptr, 'C'}, @@ -271,6 +273,7 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) { {"debug-stack-frames", required_argument, nullptr, 'D'}, {"interactive", no_argument, nullptr, 'i'}, {"login", no_argument, nullptr, 'l'}, + {"no-config", no_argument, nullptr, 'N'}, {"no-execute", no_argument, nullptr, 'n'}, {"print-rusage-self", no_argument, nullptr, 1}, {"print-debug-categories", no_argument, nullptr, 2}, @@ -331,6 +334,10 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) { opts->is_login = true; break; } + case 'N': { + opts->no_config = true; + break; + } case 'n': { opts->no_exec = true; break; @@ -467,8 +474,10 @@ int main(int argc, char **argv) { struct config_paths_t paths; // If we're not executing, there's no need to find the config. - if (!opts.no_exec) { + if (!opts.no_exec && !opts.no_config) { paths = determine_config_directory_paths(argv[0]); + } + if (!opts.no_exec) { env_init(&paths); } @@ -491,7 +500,7 @@ int main(int argc, char **argv) { parser_t &parser = parser_t::principal_parser(); - if (!opts.no_exec) { + if (!opts.no_exec && !opts.no_config) { read_init(parser, paths); } // Re-read the terminal modes after config, it might have changed them.