From d577eb4aaa3d25bb46984287e352ecffb7ac6fe7 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 12 Jul 2019 12:19:00 -0700 Subject: [PATCH] Only use the global fish_complete_path and fish_function_path Prior to this fix, fish would attempt to react if a local fish_complete_path or fish_function_path were set. However this has never been very well tested and will become impossible with concurrent execution. Always use the global values. --- CHANGELOG.md | 1 + src/complete.cpp | 5 +++-- src/function.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46f101de8..06aca0e4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Some parser errors did not set `$status` to non-zero. This has been corrected (b2a1da602f79878f4b0adc4881216c928a542608). - `string` has a new `collect` subcommand that disables newline-splitting on its input. This is meant to be used as the end of a command substitution pipeline to produce a single output argument potentially containing internal newlines, such as `set output (some-cmd | string collect)`. Any trailing newlines are trimmed, just like `"$(cmd)"` substitution in sh. It also supports a `--no-trim-newlines` flag to disable trailing newline trimming, which may be useful when doing something like `set contents (cat filename | string collect -N)` (#159). - More of the documentation, including the tutorial, is now available as man pages as well. +- Local values for `fish_complete_path` and `fish_function_path` are now ignored; only their global values are respected. ### Syntax changes and new commands - Brace expansion now only takes place if the braces include a "," or a variable expansion, so things like `git reset HEAD@{0}` now work (#5869). diff --git a/src/complete.cpp b/src/complete.cpp index e106d5245..e875976e0 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -873,8 +873,9 @@ static void complete_load(const wcstring &name) { // It's important to NOT hold the lock around completion loading. // We need to take the lock to decide what to load, drop it to perform the load, then reacquire // it. - const environment_t &vars = parser_t::principal_parser().vars(); - maybe_t path_to_load = completion_autoloader.acquire()->resolve_command(name, vars); + // Note we only look at the global fish_function_path and fish_completion_path. + maybe_t path_to_load = + completion_autoloader.acquire()->resolve_command(name, env_stack_t::globals()); if (path_to_load) { autoload_t::perform_autoload(*path_to_load, parser); completion_autoloader.acquire()->mark_autoload_finished(name); diff --git a/src/function.cpp b/src/function.cpp index a5f608548..60bb58e1f 100644 --- a/src/function.cpp +++ b/src/function.cpp @@ -104,7 +104,7 @@ static void try_autoload(const wcstring &name, parser_t &parser) { { auto funcset = function_set.acquire(); if (funcset->allow_autoload(name)) { - path_to_autoload = funcset->autoloader.resolve_command(name, parser.vars()); + path_to_autoload = funcset->autoloader.resolve_command(name, env_stack_t::globals()); } }