Let's say I want to run the process foo with different variables set, like:
FOO=1 foo
FOO=2 foo
FOO=1 BAR=7 foo
How can do do this without repeating the foo command repeatedly? E.g., by looping over the environment to set, like:
for e in 'FOO=1' 'FOO=2' 'FOO=1 BAR=7'; do
env "$e" foo
done
That almost works, except in the case with $e equal to FOO=1 BAR=1, FOO gets set to 1 BAR=1 and BAR doesn't get set at all because env sees a single argument. I could use env $e, i.e., without quoting e - but then it doesn't work if the variable values have spaces.