From 155befe90e2e9e2ab022e81f5f3661bed3c8c9e9 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 7 Apr 2016 15:44:56 -0700 Subject: Complain less about "bogus" PATH entries When determining the old path, get the existing value in any scope, not just the set scope. Also only complain about absolute paths: relative paths are expected to be invalid sometimes. --- src/builtin_set.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/builtin_set.cpp') diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index ec530599..bd871b09 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -64,16 +64,22 @@ static int my_env_set(const wchar_t *key, const wcstring_list_t &val, int scope, /* Fix for https://github.com/fish-shell/fish-shell/issues/199 . Return success if any path setting succeeds. */ bool any_success = false; - /* Don't bother validating (or complaining about) values that are already present */ + /* Don't bother validating (or complaining about) values that are already present. + When determining already-present values, use ENV_DEFAULT instead of the passed-in scope because in: + set -l PATH stuff $PATH + where we are temporarily shadowing a variable, we want to compare against the shadowed value, not the + (missing) local value. + Also don't bother to complain about relative paths, which don't start with /. + */ wcstring_list_t existing_values; - const env_var_t existing_variable = env_get_string(key, scope); + const env_var_t existing_variable = env_get_string(key, ENV_DEFAULT); if (! existing_variable.missing_or_empty()) tokenize_variable_array(existing_variable, existing_values); for (i=0; i< val.size() ; i++) { const wcstring &dir = val.at(i); - if (list_contains_string(existing_values, dir)) + if (!string_prefixes_string(L"/", dir) || list_contains_string(existing_values, dir)) { any_success = true; continue; -- cgit v1.2.3