WIP Add no-config mode

This loads *no* config, *at all*. Not even share/config.fish, so
$fish_function_path is entirely unset.
This commit is contained in:
Fabian Homborg 2021-02-15 20:57:11 +01:00
parent b3926aca63
commit 52f56e2119

View File

@ -74,6 +74,8 @@ class fish_cmd_opts_t {
std::vector<std::string> 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<std::string> *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.