OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Alternatives for heredocs in bashscripts? External templating? [duplicate]

  • Thread starter Thread starter fadedbee
  • Start date Start date
F

fadedbee

Guest
I currently use many heredocs in bash scripts.

These heredocs contain bash variables, e.g. ${MY_VAR}, which are substituted as the script executes and the heredoc is read.

Some of these heredocs have grown to hundreds of lines long, and so I would like to put these in their own files.

Unfortunately this breaks the variable substitution. I could add boilerplate to each file, turning each file into its own bash script (containing their own heredoc, which uses environment variables). This feels like pointless complexity.

Is there a way of making bash perform variable substitution on an external file as it is read in?
Continue reading...
 
Top