3 ms·
This is one reason why, really, nobody should use a shell that was optimized for commandline use, for scripting. On the commandline, all your inputs are usuall
by amelius 2y ago
This is one reason why, really, nobody should use a shell that was optimized for commandline use, for scripting.
On the commandline, all your inputs are usually known and trusted, so the shell language will take a few shortcuts to make everything more convenient for the user. But of course, when scripting, these assumptions don't hold and you need a language with more notational rigor.
Bash et al. are dangerous scripting languages, and they become even more dangerous when users (who typically don't want to understand the subtleties) start using LLMs to generate code for them.
- BoingBoomTschak 2y agoThat 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.