Sample Header Ad - 728x90

How to set environment variables dynamically for command?

8 votes
2 answers
3324 views
I would like to use some kind of minimalistic template engine with pure bash and envsubst:
user@host:~$ env -i FOO=foo BAR="bar baz" envsubst '$FOO,$BAR' \
  Reason: set -x shows that the argument for env becomes one giant string:
sh + env -i 'FOO='\''foo'\''' 'BAR='\''bar' 'baz'\''' envsubst #... env: ‘baz'’: No such file or directory ``` I must have missed a shell escape lession (again...). How might I rewrite last example to work properly?
Asked by user00705358365913 (83 rep)
Jul 22, 2022, 05:30 PM
Last activity: Jul 22, 2022, 07:56 PM