This PR adds a new Environment class that is a collection of environment variables that are owned by the Shell. These are copied into an individual WASM command's environment before the command is run, and changes are copied back out again afterwards. The copying in occurs in the preRun callback of the WASM module's constructor, which is a better place for the file system setting up so that is moved there as well.
Persistent environment variables are also required for builtin commands. A good example (the only builtin command so far) is cd which stores the current working directory in the PWD envvar and this is explicitly tested in a new test.
This PR adds a new
Environment
class that is a collection of environment variables that are owned by theShell
. These are copied into an individual WASM command's environment before the command is run, and changes are copied back out again afterwards. The copying in occurs in thepreRun
callback of the WASM module's constructor, which is a better place for the file system setting up so that is moved there as well.Persistent environment variables are also required for builtin commands. A good example (the only builtin command so far) is
cd
which stores the current working directory in thePWD
envvar and this is explicitly tested in a new test.