aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/builtin_set.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-04-07 15:44:56 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-04-07 15:44:56 -0700
commit155befe90e2e9e2ab022e81f5f3661bed3c8c9e9 (patch)
tree0d8d48c34eda70f212b6071f193bd2ae73090add /src/builtin_set.cpp
parent9347630d1e3bbe6aac342ff88378be0e31feee83 (diff)
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.
Diffstat (limited to 'src/builtin_set.cpp')
-rw-r--r--src/builtin_set.cpp12
1 files changed, 9 insertions, 3 deletions
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;