mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
parent
981a71555f
commit
d7ba6e4a1d
3 changed files with 24 additions and 17 deletions
14
env.cpp
14
env.cpp
|
@ -611,8 +611,6 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
|
||||||
bool has_changed_new = false;
|
bool has_changed_new = false;
|
||||||
int done=0;
|
int done=0;
|
||||||
|
|
||||||
int is_universal = 0;
|
|
||||||
|
|
||||||
if (val && contains(key, L"PWD", L"HOME"))
|
if (val && contains(key, L"PWD", L"HOME"))
|
||||||
{
|
{
|
||||||
/* Canoncalize our path; if it changes, recurse and try again. */
|
/* Canoncalize our path; if it changes, recurse and try again. */
|
||||||
|
@ -698,8 +696,6 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
|
||||||
mark_changed_exported();
|
mark_changed_exported();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is_universal = 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -764,7 +760,6 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
|
||||||
|
|
||||||
uvars()->set(key, val, exportv);
|
uvars()->set(key, val, exportv);
|
||||||
env_universal_barrier();
|
env_universal_barrier();
|
||||||
is_universal = 1;
|
|
||||||
|
|
||||||
done = 1;
|
done = 1;
|
||||||
|
|
||||||
|
@ -813,8 +808,6 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_universal)
|
|
||||||
{
|
|
||||||
event_t ev = event_t::variable_event(key);
|
event_t ev = event_t::variable_event(key);
|
||||||
ev.arguments.reserve(3);
|
ev.arguments.reserve(3);
|
||||||
ev.arguments.push_back(L"VARIABLE");
|
ev.arguments.push_back(L"VARIABLE");
|
||||||
|
@ -824,7 +817,6 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
|
||||||
// debug( 1, L"env_set: fire events on variable %ls", key );
|
// debug( 1, L"env_set: fire events on variable %ls", key );
|
||||||
event_fire(&ev);
|
event_fire(&ev);
|
||||||
// debug( 1, L"env_set: return from event firing" );
|
// debug( 1, L"env_set: return from event firing" );
|
||||||
}
|
|
||||||
|
|
||||||
react_to_variable_change(key);
|
react_to_variable_change(key);
|
||||||
|
|
||||||
|
@ -899,7 +891,6 @@ int env_remove(const wcstring &key, int var_mode)
|
||||||
ev.arguments.push_back(L"VARIABLE");
|
ev.arguments.push_back(L"VARIABLE");
|
||||||
ev.arguments.push_back(L"ERASE");
|
ev.arguments.push_back(L"ERASE");
|
||||||
ev.arguments.push_back(key);
|
ev.arguments.push_back(key);
|
||||||
|
|
||||||
event_fire(&ev);
|
event_fire(&ev);
|
||||||
|
|
||||||
erased = 1;
|
erased = 1;
|
||||||
|
@ -914,6 +905,11 @@ int env_remove(const wcstring &key, int var_mode)
|
||||||
if (erased)
|
if (erased)
|
||||||
{
|
{
|
||||||
env_universal_barrier();
|
env_universal_barrier();
|
||||||
|
event_t ev = event_t::variable_event(key);
|
||||||
|
ev.arguments.push_back(L"VARIABLE");
|
||||||
|
ev.arguments.push_back(L"ERASE");
|
||||||
|
ev.arguments.push_back(key);
|
||||||
|
event_fire(&ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,15 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
set -eU __fish_test_universal_variables_variable_foo
|
set -eU __fish_test_universal_variables_variable_foo
|
||||||
|
function watch_foo --on-variable __fish_test_universal_variables_variable_foo
|
||||||
|
echo Foo change detected
|
||||||
|
end
|
||||||
|
|
||||||
|
set -U __fish_test_universal_variables_variable_foo 1234
|
||||||
|
set -eU __fish_test_universal_variables_variable_foo
|
||||||
|
|
||||||
|
functions -e watch_foo
|
||||||
|
|
||||||
|
|
||||||
# test erasing variables without a specified scope
|
# test erasing variables without a specified scope
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ Test 12 pass
|
||||||
Test 13 pass
|
Test 13 pass
|
||||||
Test 14 pass
|
Test 14 pass
|
||||||
Test 15 pass
|
Test 15 pass
|
||||||
|
Foo change detected
|
||||||
|
Foo change detected
|
||||||
Test 16 pass
|
Test 16 pass
|
||||||
Testing Universal Startup
|
Testing Universal Startup
|
||||||
1
|
1
|
||||||
|
|
Loading…
Reference in a new issue