Explorar el Código

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.
Ali Mohammad Pur hace 3 años
padre
commit
6a245de911
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      Userland/Shell/Builtin.cpp

+ 7 - 0
Userland/Shell/Builtin.cpp

@@ -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;
 }