I have a myfile
which contains lines like
#!/usr/bin/env python3
print("Hello world")
names = ('${(j:', ':)ZSH_VAR[@]}', )
I would like to pre-process this file with the environment variables in my loaded shell (zsh
in my case, but a generic bash
solution would also work nicely).
How can I do the equivalent of
$ declare -ga ZSH_VAR=( 1 2 3 )
$ preprocess < myfile
Such that the output is
#!/usr/bin/env python3
print("Hello world")
bar=('1', '2', '3', )