common: New function substitute_vars.
* common/stringhelp.c (substitute_envvars): Factor code out to (substitute_vars): new. (subst_getenv): New.
This is a generalized version of substitute_envvars.
(cherry picked from commit 7b7fdf45e5d8b3b066c5efbf6ec872e1249f3a24)