Closed dundalek closed 6 years ago
I created a pull request for (getenv) and (setenv). It seems omitting the '!' is the way you're going with other things. I agree with this, as it's cumbersome to type and this is a shell--lots of stuff is going to be mutable.
I think more needs to be done though. I haven't fully thought this through, but it seems closh will need shell local and exported (environment) variables just like other shells. Any thoughts on how to handle that?
As for setting an environment variable only for a child process, closh can do the same thing fish does and just rely on an external env
command. E.g.
$ env P=1 bash -c "echo $P"
1
This works, but I can't help thinking there is a more elegant solution.
I like the reasoning behind omitting the bang.
Sweet, that's a pretty nifty trick with the env
command. I am glad it works so we don't need to add an additional function.
Implemented in the PR
As for now one can use the JS interop to access and set environment variables:
Maybe we want to introduce helper functions like
(setenv)
or(setenv!)
and(getenv)
?Another thing is setting an env variable only for the child process, alternative to bash:
NODE_ENV=production npm start