3 ms·
Because you're not going to have a great time with /bin/sh (i.e. dash or the like) if you want to do anything more than very, very basic scripts.
by cure 5y ago
Because you're not going to have a great time with /bin/sh (i.e. dash or the like) if you want to do anything more than very, very basic scripts.
- netr0ute 5y agoRelying on bash is a recipe for non-portability.
- lamontcg 5y agoIf you're not publishing your scripts and you're running your own infrastructure, you probably don't care about portability at all.
- chasil 5y agoNone of the BSDs use bash in their base. Apple recently switched from bash to zsh. OpenBSD uses a descendent of pdksh. Another major user of a pdksh descendent is Android (mksh), with a truly massive install base. Some of the bash problem, besides portability, is GPLv3. That was a major factor for Apple. I don't want my script portability linked to corporate patent issues. For this and other reasons, I don't use bash-specific features, ever.
- lamontcg 5y agoYeah I've written and maintained scripts for the past 10 years that have to run on stock Solaris, AIX and *BSD. When they started out they had to work on the Solaris 9 /bin/sh, which is particularly elderly. You should feel free to continue to write portable scripts. That is horrible advice for anyone who is just starting out though and they should stick with #!/bin/bash and not worry about it until they actually want to consider platforms other than Linux. Portability is the wrong thing for people who are learning to focus on. It is also bad advice for most system administrators at most businesses since they won't have those alternative *nixes either, and its a best practice to minimize how many different operating systems you have to care about.
- chasil 5y agoAs we've already covered, Ubuntu is your downfall. Almquist is in Ubuntu for two reasons: speed and standards compliance. These may not be important to you, but they are to a great many people, and the horrible advice in this case is to disregard these factors.
- lamontcg 5y ago#!/bin/bash People who start out with linux should use that. Most companies, particularly HNey startups, should use that and nothing bad will happen. Most people don't have to care about portability, shouldn't use /bin/sh, and shouldn't learn about Almquist. Your advice does not favors to the bulk of people who just need to get shit done. If they do wind up working in an environment where it is important, they can teach themselves the differences at that point, or else ask someone like us to review their code (and there's an automated linter out there). You aren't the Main Character, most people don't need to care about the same things that you do.