2 ms·
No one else seems to have mentioned this, but POSIX sh does not include this feature. Until it does, and major POSIX shs have shipped with it for a decade, the
by DiabloD3 2y ago
No one else seems to have mentioned this, but POSIX sh does not include this feature.
Until it does, and major POSIX shs have shipped with it for a decade, then the feature will actually exist in a way that the average shell coder cares about. You're better off just shipping Rust/Go/etc binaries and leave sh for your simple glue tasks.
Even I've eventually switched to this, and I've written 10k+ long Bash scripts that followed best practices and passed shellcheck's more paranoid optional tests.
Use the right language for the right job.
- abathur 2y ago> then the feature will actually exist in a way that the average shell coder cares about I think it's worth picking at this a bit. At least IME, a fairly small fraction of the Shell I write needs to run literally (any|every)where. I don't mean to suggest there aren't people/projects for whom the opposite is true--just that it's worth chunking those cases and thinking about them differently. It obviously isn't a global solution, but in the Nix ecosystem we have decent idioms for asserting control over the shell and tools any given script runs with. Reliable environment provisioning can spare hundreds of lines of code real-world Shell tends to accumulate to sanity-check the runtime environment and adapt to the presence/absence of various utilities. It also enables us to use newer shells/features (and shell libraries) with confidence. It's enough leverage that I only give it up when I must.
- nmz 2y agoPOSIX sh doesn't even have arrays. I remember having to use awk for that functionality.