SAM is a command line tool (for Slackware Linux) which uses a stack to provide control of variables, including PATH, and functions. To do this it uses a set of scripts, functions and compiled code. The result is a command line environment that changes the way you see and thus changes the way you think. It has helped me to write more and better shell code. Perhaps it will help you also.