kvz / bash3boilerplate

Templates to write better Bash scripts
http://bash3boilerplate.sh
MIT License
2.12k stars 198 forks source link

src/templater.sh should be replaced or removed #97

Closed mstreuhofer closed 6 years ago

mstreuhofer commented 6 years ago

templater.sh does its magic trying to use sed. this works out fine as long as there is no surprise in any env var. this cannot even really be fixed as such because really sed is the wrong tool for this job. possibly use perl where quoting (\Q and \E) can be used or do as most others suggest and use eval+cat. or at least try to replace only vars which actually get referenced in the template and live with the fact that if this variable has unexpected content stuff breaks - right now a sed command is issued for each existing env var. this is bound to break no matter what.

opinions? remarks? ideas?

zbeekman commented 6 years ago

I like removing reliance on tools other than bash whenever possible for this project so my vote is for eval+cat, or some other technique that doesn't require sed/awk/perl. Probably an all awk solution would be better than sed+awk. But TBH, I'll completely defer to you guys on this one. This level of text processing wizardry is starting to get out of my depth.

kvz commented 6 years ago

I'd be fine with accepting an improved version, as I don't have the time to invest myself. Removing would be unideal for my own use of the project :)

mstreuhofer commented 6 years ago

wrt #98 i have to say that i did not really fix anything. all i did was switch to perl if it is available. the original shell/sed/awk code is still there and it is still broken. so as long as we are all clear about that.. :)