Reputation: 19477
I have a bunch of customizations and would like to run my test program in a pristine environment. Sure I could use a tiny shell script to wrap and pass of arguments but it would be cool and useful if I could invoke a pre and possibly post script only to commands located under certain sub directories. The shell I'm using is zsh.
Upvotes: 2
Views: 214
Reputation: 72609
If by pristine environment you mean a fully controlled set of environment variables, then the env
program does this.
env -i PATH=$PATH HOME=$HOME program args
will run program args
with only the environment variables you specified.
Upvotes: 0
Reputation: 107739
I don't know what you include in your “pristine environment”.
If you want to isolate yourself from the whole system, then maybe chroot is what you're after. You can set up a complete new system, with its own /etc
, /bin
and so on, but sharing the kernel, networking and other non-filesystem stuff with your running system. Root's cooperation is required (the chroot
system call is reserved to root).
If you want to isolate yourself from your dot files, run the program with a different value for the HOME
environment variable:
HOME=~/test-environment /path/to/test-program
HOME=~/test-environment zsh
If this is specifically about zsh's configuration files, you can set the ZDOTDIR
environment variable before starting it to tell zsh to run its own dot files from a directory other than $HOME
(or zsh --no-rcs
to not load any dot file).
Upvotes: 1