3 ms·
That example is pretty sad, the solution has always been the same (even in sh), use an argv based wrapper instead of something like system(3): exec(`figlet "
by BoingBoomTschak 2y ago
That example is pretty sad, the solution has always been the same (even in sh), use an argv based wrapper instead of something like system(3):
exec(`figlet "Welcome, ${username}" | lolcat -f`)
// Should be
spawn(["sh", "-c", "figlet \"Welcome, $1\" | lolcat -f", "argv0", username])
> This is one reason why, really, nobody should use a shell that was optimized for commandline use, for scripting.
Tcl showed me you can have your cake and eat it, you just need sane quoting rules (like don't make IFS splitting the default and use matched braces for your quoting syntax to solve nesting) and arrays to escape the infamous quoting hell.
Though I agree that sh is dangerous for newbies, I always advise "1. ALWAYS set -eu, 2. shellcheck" to them.
- amelius 2y ago> Though I agree that sh is dangerous for newbies The problem is that expert users of sh will write scripts that newbies may at some point modify. This would be much safer if the scripts were originally in a better language. Bash is a footgun. Even expert users have shot themselves in the foot with it at some point in their career.