Loop resolving environment variables

If an environment variable resolves to contain a different environment
variable it also needs to be resolved.