Shopify / shadowenv

reversible directory-local environment variable manipulations
https://shopify.github.io/shadowenv/
MIT License
396 stars 18 forks source link

Add append_to_pathlist #33

Closed lugray closed 5 years ago

lugray commented 5 years ago
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$ mkdir -p demo/.shadowenv.d
$ echo '(env/append-to-pathlist "PATH" "/sentinel")' > demo/.shadowenv.d/demo.lisp
$ cd demo
shadowenv failure: directory contains untrusted shadowenv program: shadowenv help trust to learn more.
$ shadowenv trust
activated shadowenv
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/sentinel
$ cd ..
deactivated shadowenv
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

It's worth noting that the behaviour is already allowed, this just makes it easier and more clear:

(if (null (env/get "PATH"))
  (env/set "PATH" "/sentinel")
  (env/set "PATH" (concat (env/get "PATH") ":/sentinel" )))