Shell: Refresh PATH cache after 'unset PATH'

Note that `execvp` has a default value for PATH (both on Serenity and on
Linux) and so this does not 'fix' #11608.
This commit is contained in:
Ali Mohammad Pur 2022-01-05 08:04:19 +03:30 committed by Andreas Kling
parent 310a18da1e
commit 6a245de911

View file

@ -1028,7 +1028,11 @@ int Shell::builtin_unset(int argc, const char** argv)
if (!parser.parse(argc, const_cast<char**>(argv), Core::ArgsParser::FailureBehavior::PrintUsage))
return 1;
bool did_touch_path = false;
for (auto& value : vars) {
if (!did_touch_path && value == "PATH"sv)
did_touch_path = true;
if (lookup_local_variable(value)) {
unset_local_variable(value);
} else {
@ -1036,6 +1040,9 @@ int Shell::builtin_unset(int argc, const char** argv)
}
}
if (did_touch_path)
cache_path();
return 0;
}