Instead of querying the operating system for current working directory and environment variables, this function now accepts those things as inputs.