From 6a245de91170acc9183ea780c6c90f25fa7c2bc3 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 5 Jan 2022 08:04:19 +0330 Subject: [PATCH] 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. --- Userland/Shell/Builtin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index f301cffc1b..ea5b04cf80 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -1028,7 +1028,11 @@ int Shell::builtin_unset(int argc, const char** argv) if (!parser.parse(argc, const_cast(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; }