How can I execute a program (specifically a bash alias) with the default environment variables?
Consider this example:
export test="something I dont want to exist"
alias _xterm='xterm -fn 7x13 -fa "Ubuntu Mono:size=12:antialias=false"'
_xterm
In the spawned xterm
instance, the variable $test
shouldn't be set.
You could execute your command in an empty environment:
A quick test harness:
Preserving
$DISPLAY
,$USER
, etc:Or you could explicitly exclude just some variables with the
env -u
option:The names of default environment variables are written with capital letters. Now, assuming that you will define new environment variables with tiny letters (as it is in your example
test
), instead to use a simple alias_xterm
, you can use a function_xterm
where you have to unset the new environment variables and keep only the default environment variables for the new shell instance:Like this, your new environment variables are not available in the new shell instance, but when you comeback to the old shell instance you can still use them.