TempleOS has something like a set of environment variables for each task - if the user asks for a variable and it isn't found, then the parental task's variables are checked, followed by the next parental task's variables etc., all the way up to Adam, which would be like global environment variables.
http://www.templeos.org/Wb/Doc/Mysteries.html