diff --git a/src/env.cpp b/src/env.cpp index a3aaf68d2..c05c13ecc 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -81,7 +81,6 @@ size_t read_byte_limit = READ_BYTE_LIMIT; static const wchar_t PATH_ARRAY_SEP = L':'; static const wchar_t NONPATH_ARRAY_SEP = L' '; -bool g_use_posix_spawn = false; // will usually be set to true bool curses_initialized = false; /// Does the terminal have the "eat_newline_glitch". @@ -779,11 +778,6 @@ void env_init(const struct config_paths_t *paths /* or NULL */) { vars.set_termsize(); // initialize the terminal size variables vars.set_read_limit(); // initialize the read_byte_limit - // Set g_use_posix_spawn. Default to true. - auto use_posix_spawn = vars.get(L"fish_use_posix_spawn"); - g_use_posix_spawn = - use_posix_spawn.missing_or_empty() ? true : bool_from_string(use_posix_spawn->as_string()); - // Set fish_bind_mode to "default". vars.set_one(FISH_BIND_MODE_VAR, ENV_GLOBAL, DEFAULT_BIND_MODE); diff --git a/src/env_dispatch.cpp b/src/env_dispatch.cpp index ddadc8427..ed84ddc77 100644 --- a/src/env_dispatch.cpp +++ b/src/env_dispatch.cpp @@ -300,6 +300,13 @@ static void handle_curses_change(const environment_t &vars) { init_curses(vars); } +static void handle_fish_use_posix_spawn_change(const environment_t &vars) { + // note this defaults to true + auto use_posix_spawn = vars.get(L"fish_use_posix_spawn"); + g_use_posix_spawn = + use_posix_spawn.missing_or_empty() ? true : bool_from_string(use_posix_spawn->as_string()); +} + /// Populate the dispatch table used by `env_dispatch_var_change()` to efficiently call the /// appropriate function to handle a change to a variable. /// Note this returns a new-allocated value that we expect to leak. @@ -327,6 +334,7 @@ static std::unique_ptr create_dispatch_table() { var_dispatch_table->add(L"fish_read_limit", handle_read_limit_change); var_dispatch_table->add(L"fish_history", handle_fish_history_change); var_dispatch_table->add(L"TZ", handle_tz_change); + var_dispatch_table->add(L"fish_use_posix_spawn", handle_fish_use_posix_spawn_change); return var_dispatch_table; } @@ -336,3 +344,6 @@ static void run_inits(const environment_t &vars) { handle_curses_change(vars); update_wait_on_escape_ms(vars); } + +// Miscellaneous variables. +bool g_use_posix_spawn = false;