Skip to content

Instantly share code, notes, and snippets.

@paulwib
Created September 17, 2021 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulwib/239da597ed7af7468a81d15fd0a66208 to your computer and use it in GitHub Desktop.
Save paulwib/239da597ed7af7468a81d15fd0a66208 to your computer and use it in GitHub Desktop.
Dangerously expanding a file with environment vars
#!/usr/bin/env sh
export BAR="living on the edge"
export FRED="be careful!"
eval "echo \"$(cat file_with_vars.txt)\""
# Here's my vars, now I want to expand them with content from my shell environment variables
FOO=$BAR
FRED=$QUX
@paulwib
Copy link
Author

paulwib commented Sep 17, 2021

Probably a better option is envsubst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment