mattly / bork

the Bash-Operated Reconciling Kludge
Other
218 stars 29 forks source link

Don't use eval in bake #136

Closed ricochet1k closed 6 years ago

ricochet1k commented 6 years ago

Using eval in bake breaks simple commands like sed -e '/^a$/,/^b$/{/^a$/d; /^b$/d; p; }' $targetfile with an error message like

/dotfiles/external/bork/lib/helpers/bake.sh: eval: line 1: syntax error near unexpected token `}'
/dotfiles/external/bork/lib/helpers/bake.sh: eval: line 1: `sed -n -e /^a$/,/^b$/{ /^a$/d; /^b$/d; p; } test_target

because the quotes are lost and then eval tries to reinterpret everything. Using just "$@" preserves the existing word breaks and runs as a command.

ricochet1k commented 6 years ago

A more pervasive problem is that $* is used everywhere. This is bad, and the clearest explanation I've been able to find is here: https://stackoverflow.com/a/14247867/678437

So essentially, any time someone wants to use filenames or other arguments that contain spaces, things are going to break.

ricochet1k commented 6 years ago

Sorry, I just barely saw #126, It's good that this is already known.