Support expansions of ENV_* vars in all options.

Rebase `ENV_*` expansion patch on top of 3.0 branch.