News for hackers. Stuff that matters.
Re:Pure sh bible – Posix sh alternatives to external processes by quotemstr on Monday October 19, 2020 @04:32PM (#24830670)
As you should. Bash --- at least bash 3.x --- is available literally everywhere and has many features essential for robust programming, like local variables. Instead of writing for some antique shell, we should all just write for bash or zsh or something modern. I don't care about being compatible with some random AIX installation that's from 1870 and powered by a steam engine.
Re:Pure sh bible – Posix sh alternatives to external processes by saagarjha on Monday October 19, 2020 @08:45PM (#24832831)
sh is used because it is POSIX sh–you know it will work not "literally everywhere" but really, truly, literally everywhere. And your bashisms aren't going to do all that well on BusyBox, or dash. Just because you don't care doesn't mean that we should make incompatible scripts and not be aware that we are doing so.
Re:Pure sh bible – Posix sh alternatives to external processes by umanwizard on Monday October 19, 2020 @05:40PM (#24831327)
One counterexample: bash isn’t available in the base system of typical BSD variants (though, yes, you can install it from ports).
Re:Pure sh bible – Posix sh alternatives to external processes by wl on Monday October 19, 2020 @08:54PM (#24832912)
I've worked on storage-constrained embedded systems where adding bash and its dependencies expanded my root filesystem by 50%. busybox ash is a much smaller alternative.
Re:Pure sh bible – Posix sh alternatives to external processes by scoopertrooper on Monday October 19, 2020 @11:55PM (#24833793)
Security teams love stripping bash out of linux images. I was forced into living a pure sh diet while working for a bank.
Re:Pure sh bible – Posix sh alternatives to external processes by klodolph on Monday October 19, 2020 @07:23PM (#24832190)
If I want to use modern features, I’ll just use Perl or Python, both of which are also available literally everywhere.
Re:Pure sh bible – Posix sh alternatives to external processes by dimitrios1 on Monday October 19, 2020 @08:48PM (#24832859)
Or I'll just write it in Go and easily cross compile an execuable binary for whatever platform I need.
Re:Pure sh bible – Posix sh alternatives to external processes by jgtrosh on Monday October 19, 2020 @04:45PM (#24830822)
It is however useful to know the difference, and in some cases you actually need to write POSIX (code meant to be sourced for example).
Re:Pure sh bible – Posix sh alternatives to external processes by nucleardog on Tuesday October 20, 2020 @05:33AM (#24835415)
As others have mentioned... not everywhere. And sometimes you’re just writing something that really shouldn’t require a dependency on bash.

You wouldn’t write a Python script to run a few quick shell commands like copying a few files around. Same concept.

Re:Pure sh bible – Posix sh alternatives to external processes by trasz on Monday October 19, 2020 @06:05PM (#24831560)
This would make sense if it said "zsh" instead. Not only is only better in terms of features, it's also released under a non-problematic Open Source license.