Unset an environment variable for a single command
Technically, they're not environment variables until someone export
s them. But you can at least set them to empty:
FOO= some command
If removing them from the environment is enough, you can use env
:
env -u FOO somecommand
env -u FOO somecommand
This will remove the environment variable FOO
from the somecommand
process' environment.
And to unset multiple variables:
env -u FOO -u FOO2 somecommand
For anyone intending to run a command with none of their environment variables, you can do so by running:
env -i somecommand