Haskell's System.Process
provides us with a way to convert a String
into a shell command via shell
:
System.Process.createProcess (System.Process.shell $ "a_command with some arguments")
The problem is that shell
doesn't parse environment variables. Is there a library command which converts a shell string into a shell call, that is sensitive to environment variables? Something like
System.Process.createProcess (shellWithEnv "ENVIRONMENT_VARIABLE=value a_command with some arguments")
?
EDIT: More evidence shell
does not pick this up:
GHCI> shell "ENV=value echo hi"
CreateProcess {cmdspec = ShellCommand "ENV=value echo hi", cwd = Nothing, env = Nothing, std_in = Inherit, std_out = Inherit, std_err = Inherit, close_fds = False, create_group = False, delegate_ctlc = False, detach_console = False, create_new_console = False, new_session = False, child_group = Nothing, child_user = Nothing, use_process_jobs = False}
Here env = Nothing
.
Read more here: https://stackoverflow.com/questions/67010887/parsing-a-shell-command-with-environment-variables-in-haskell
Content Attribution
This content was originally published by George at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.