We have been trying to understand why the Mac OS Terminal, when invoked with open, does not pass along the environment variables.
How to reproduce?
Create a new file /tmp/example.sh
#!/bin/sh
echo "SAMPLE_ENV='$SAMPLE_ENV'"
SAMPLE_ENV=123 open -a Terminal /tmp/example.command
Only prints: SAMPLE_ENV=''
Even when using
SAMPLE_ENV=123 open --env SAMPLE_ENV=1234 -a Terminal /tmp/example.sh
it will only print SAMPLE_ENV=''
We know for sure that this was working several years ago. Why was the feature removed or is this a bug?
Any workaround?
Is there a workaround on how to launch a script in a new Terminal Window while passing the environment variables correctly?
Related
https://stackoverflow.com/questions/69768133/react-native-envs-are-undefined-in-metro-bundlers-config-file-when-bundling/73036234