| ▲ | garethrowlands an hour ago | |
Articles like this are fun but they all come from posix shell syntax being fundamentally bad for scripting/programming. All the piping stuff is great, of course. And the overall ecosystem is great. But the interpretation of the script itself working by a series of string substitutions is a mechanism we wouldn't accept in a regular programming language. And there's no excuse for it really, except that shell syntax is really, really old. For example, what does `$foo` mean in shell syntax? In any reasonable language (perl or powershell, for example, or python if you drop the `$`), it's an expression that evaluates to whatever value's inside that variable. In shell, `$foo` isn't an expression in that sense, and what it does depends on what's inside it via a variety of string substitution rules. This is the main reason we have arcane articles like this. That said, nice article. | ||
| ▲ | bityard 15 minutes ago | parent | next [-] | |
I feel the need to push back on this perspective. Old doesn't imply arcane. It instead can (and does, in this case) mean that it won out over the course of decades against other less worthy alternatives. Although you can write "programs" in sh, the shell syntax was never meant to be anything like a systems or application programming language. It was meant to efficiently automate systems tasks. It is kind of like the fork lift of computing. It does it's job very well, is bad at doing anything else, yet no other kind of vehicle can do it's job nearly as efficiently. Comparing the shell to C, Go, Rust, Python, or JavaScript is crazypants. It has a different job than those, so of course it will look and feel different! | ||
| ▲ | amelius an hour ago | parent | prev | next [-] | |
Yes a large percentage of bash scripts fails if you feed them filenames with spaces or other special characters. Or a large amount of filenames near the Unix maximum commandline length. Bash et al are great for command line use, but produce a situation of really bad engineering hygiene when used in scripts. Do not use. Stay away. Bash et al considered harmful. | ||
| ▲ | layer8 an hour ago | parent | prev [-] | |
Your `$foo` example confused me at first because I thought the backticks are part of the example. | ||