Command::env_clear but path still set?

Here's the playground:

Any ideas why the grep executable is being found despite having no env vars set (as env_clear is set)?

Even if I run sh and get it to call set there's env vars....

Is there some special casing of 0 env vars set that defaults to just using the parent's set of envs somewhere?

I've tried OSX and Linux OSes and the same thing happens... am puzzled.

I'm not sure why the existence of a binary should depend on the environment variables.

However, this indeed is surprising. Yet, if you call env instead of sh -c set, you will get an empty output. This suggests to me that it's the shell that still somehow defines or bakes in defaults for some environment variables.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.