5 ms·
> there is a very clear baseline of functionality that works in every Bourne/POSIX descendant Where is the best place to learn what this is? I'd love to make s
by crabmusket 4y ago
> there is a very clear baseline of functionality that works in every Bourne/POSIX descendant
Where is the best place to learn what this is? I'd love to make sure I'm writing portable shell scripts when I do have to.
There's also the issue that "shell scripts" often involve using binaries which you might not even realise are binaries (is "echo" a shell builtin or a binary? I forget) and which may differ from system to system. I've been bitten by grep issues before writing scripts across Ubuntu and OSX.
- JamesonNetworks 4y agoChatGPT has done wonders for my understanding of bash. I presents me with lots of tedious things I would never spend time learning
- deleted 4y ago[deleted]
- nikvdp 4y agohttps://www.shellcheck.net/ https://www.shellcheck.net/ and it’s accompanying cmdline tool/ lsp integrations is a lifesaver for preventing that kind of thing. It’ll warn you if you’re doing anything not portable and even smartly changes it’s behavior depending whether your shebang line uses bash or sh (iirc)
- cpach 4y agoDo you need portable shell scripts though? IMHO, it really depends on the context. If I was about to ship an open source application that came bundled with some shell scripts, then I agree portability is good, so that I know the script would run for people who might not have Bash installed. But at ${DAYJOB} I much prefer to let Bash run all my scripts, and I make that explicit via ‘#!/usr/bin/env bash’. Bash is still evolving and the Bash devs are adding new features that I would miss in pure sh. Case in point: A (somewhat) reasonable way of working with arrays.