Replacement for old curl_env. Total rewrite.
Remove dependency on bash_function_init submodule.