I'm trying to run a shell command from Julia which needs to have an environment variable set to some specific value. I have two problems:
How to set environment variables to be used by Julia's
run(command, args...; wait::Bool = true)command?How to pass special sign
$to this process without interpolating it? I want to test if the variable is available for my program.
What I have done so far:
Let's say I want to define an environment variable FOO=bar and check if it's accessible within the shell with shell command echo $FOO.
To prevent Julia interpolating $ I already quoted it like explained in the official documentation but then echo is printing $PATH and not its value.
So for FOO I got the following output
julia> run(`echo '$FOO'`)
$FOO
Process(`echo '$FOO'`, ProcessExited(0))
but would have expected something like
julia> run(`echo '$FOO'`)
Process(`echo '$FOO'`, ProcessExited(0))
if FOO is undefined or
julia> run(`echo '$FOO'`)
bar
Process(`echo '$FOO'`, ProcessExited(0))
if the value is set to bar.
PATH, so something like/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin. I edited my question accordingly. - AnHeuermannFOO- AnHeuermann