turtle
turtle copied to clipboard
Environmental variables example missing in tutorial
Maybe I just didn't notice it, but in my opinion this is a must have for anyone writing shell scripts. I know I can use System.Environment, perhaps Turtle should consider re-exporting it (or maybe only lookupEnv as getEnv)?
I actually do provide environment variable utilities, but only for more recent versions of base. See here, specifically export, unset and need:
https://github.com/Gabriel439/Haskell-Turtle-Library/blob/master/src/Turtle/Prelude.hs#L104
I depend on base to provide platform-agnostic environment variable manipulation, which is why older versions of base don't support those utilities.
The tutorial doesn't mention them yet because they are not supported in ghc-7.4 (which is what Debian stable uses). Once Debian stable has a newer version of ghc then I will more publicly advertise those utilities.
Does this solve your issue?
Current Debian stable uses ghc-7.6.3: https://packages.debian.org/stable/ghc
@Gabriel439, I would say that we're missing a pure option of using the environment vars, as follows:
[nix-shell:~/src/iohk]$ echo $FOO
[nix-shell:~/src/iohk]$ FOO=1 bash -c 'echo $FOO'
1
[nix-shell:~/src/iohk]$ echo $FOO
..which only sets FOO in the scope of the subprocess.
Should I file a separate issue for that?
@deepfire: You can do this indirectly using the subprocess runners that take a CreateProcess as an argument, such as Turtle.Prelude.system and Turtle.Prelude.stream. The CreateProcess record provides an env field that lets you specify a temporary environment to pass to the subprocess
@Gabriel439, strictly speaking you're right -- but do you also think that this is a bit cumbersome, and desirable to be improved?
The main issue is that adding support for this would double the already high number of subprocess runners in the API. It's also not clear that it would significantly improve on the CreateProcess-based API