News for hackers. Stuff that matters.
Re:Shell Style Guide by pas on Tuesday May 15, 2018 @10:41AM (#17074237)
Why wouldn't you install Bash then, if you want to run shell scripts on those platforms?

I mean, what are the use cases? Where universality is important (so let's say when someone embeds scripts in Makefiles), I understand the need for POSIX, but other that I can't even come up with a good use case for having sh as default. (Maybe to save space, you ship the embedded device or Docker container with sh, sure, but then what kind of script you'd want to run there? Okay, maybe all of them, but then even on alpine installing bash is one quick command.)

Re:Shell Style Guide by saagarjha on Tuesday May 15, 2018 @01:24PM (#17075702)
> Why wouldn't you install Bash then, if you want to run shell scripts on those platforms?

Busybox is a thing. Many embedded devices don't have the luxury of installing Bash–you're stuck with what you've got.

Re:Shell Style Guide by pas on Wednesday May 16, 2018 @05:31PM (#17086680)
But what would a script do in such a limited situation? There are a lot of narrow use cases, but those are very much platform dependent, so no reason to use POSIX everywhere. Use whatever is best on that specific busybox thing.
Re:Shell Style Guide by Sir_Cmpwn on Tuesday May 15, 2018 @10:58AM (#17074394)
>but then what kind of script you'd want to run there? Okay, maybe all of them

I think you answered your own question here.

I can elaborate, though. bash isn't portable, it uses Glibc-isms. It has to be explicitly ported to new platforms. I also pointed out elsewhere that the value-add of bash is dubious at best - if you need to use bashisms you're better off not writing a shell script at all. So really, the question is: why do you need bash? You have to justify using non-standard tools, not the other way around.

Re:Shell Style Guide by pas on Tuesday May 15, 2018 @11:21AM (#17074591)
The mentioned "file transfer shell-program" somehow was so important that it has to run on AIX and Linux and every other OS under the sun, yet it was somehow not important enough to be written in non-sh.

And I feel the same with targeting POSIX sh.

Unless you have a really good business niche - like the aforementioned ftp script, use a proper language.

Yes, sysadmins were opposed to installing Bash. But if your core product depends on Bash and only on Bash, maybe I'd be opposed to everything about that deployment too.

And at the same time, I understand that there are IT tasks well suited to be solved with a script. But those don't seem to be the ones that require uber-portability.

If I need to setup something on a fleet of VMS-es, I'll use whatever I can get away with (including a lot of controlled substances to handle the dread of handling VMS), and won't think about what happens if we port this to HP-UX in the year 2525.

Re:Shell Style Guide by Sir_Cmpwn on Tuesday May 15, 2018 @11:28AM (#17074657)
There are many, many cases where a shell script is appropriate. I don't see a shell script as inherently evil, especially if you use one as conservative as POSIX sh. I ship shell scripts with my software often and for a wide variety of tasks.