I have a follow-up question regarding Shell out from ruby while setting an environment variable. I try to feed the environment variable to a shell script via sudo, but not successful.
This is the sample one-line script, "/usr/bin/wrapper.sh".
echo $MYVAR
Test,
$ irb
> system({'MYVAR' => "42"}, "echo $MYVAR") ==> GOOD
> system({'MYVAR' => "42"}, "wrapper.sh") ==> GOOD
> system({'MYVAR' => "42"}, "sudo echo $MYVAR") ==> GOOD
> system({'MYVAR' => "42"}, "sudo wrapper.sh") ==> NOT GOOD
Thanks for the help.
exportso it affects subshells.wrapper.shis not running in the same process assudo's immediate shell. DoesENV['MYVAR'] = 42before running it propagate properly?