5 ms·
I suspect that many folks who "don't run bash" actually do use bash quite a bit, e.g. in initscripts and various software packages.
by inportb 12y ago
I suspect that many folks who "don't run bash" actually do use bash quite a bit, e.g. in initscripts and various software packages.
- stephenr 12y agoAny decent shell script is written to use "sh" not bash, and on debian/etc sh is provided by dash not bash. So while a lot of people are affected, your reasoning points to other issues that are very solveable
- erikb 12y agoThis more of a "should be", right? Maybe most shell scripts should use "sh" but I see "bash" way more often.
- stephenr 12y agoI guess it comes down to how you interpret things. I specifically said any decent shell script. My logic is that if it is not using "sh", but instead relying on bash (or any other specific shell really), it's not a decent shell script. If I were to amend the sentence to make the meaning clearer, I would still not use "should be", I would use "must be".
- yen223 12y agoIf you can confidently assert that every shell script your system runs is "decent", then you'll have no problem. The thing is, very few of us can confidently make that assertion.
- stephenr 12y agoThat all depends where your shell scripts come from. In my experience most of the shell scripts provided by packages for debian, do use /bin/sh. A quick check of .sh files on a couple of squeeze/wheezy installs showed that the vast majority of shell scripts using Bash come from node modules, which quite frankly is not surprising.
- eropple 12y agoYou're overreaching. I write scripts against bash, not sh, because it's a better scripting language for what I need. It's more readable and its constructs are easier (for me) to follow. I don't care about POSIX-compatibility when bash can be installed literally anywhere. It's a dependency for the devops stuff that I run and maintain, much like Ruby is a dependency and all the gems in my Gemfile. It's a considered decision, not a sign of "indecency".
- stephenr 12y agoI suggest you read the accepted answer at http://stackoverflow.com/questions/19428418/what-is-the-use-of-portable-shell-scripts http://stackoverflow.com/questions/19428418/what-is-the-use-... for a brief look at why portable shell scripts are a better solution than bash specific scripts.
- eropple 12y agoI suggest you read my post and maybe let it roll around your head that I've considered my environment and the domain of my problems in a way you aren't giving me credit for. Perhaps even, with that whole mention of devops, I do something such as--crazy thought incoming--install an updated version of bash on every system I must provision, just as I do Ruby, Python, etc.? "Decent shell script" is not a synonym for "portable shell script" and the presumption therein is what I was addressing.
- sigzero 12y agoExactly so. If I want PORTABLE, I write to "sh". If I want BASH, I write to BASH. The term "decent shell script" is wrong the way he uses it.
- mysidia 12y agoPerhaps he didn't deliver the point... but BASH is not a good or safe language to write to. Writing to '/bin/sh' is understandable due to its ubiquitousness. Bash is a superset that is not so ubiquitous, so it doesn't have the advantage that writing to /bin/sh does. If you don't want portable, then don't write to shell script. Write to Perl Ruby or Python, which is also safer and more secure.
- TeMPOraL 12y agoStill, isn't sh quite often implemented as an alias/symlink for bash nowdays?
- samuellb 12y agoYes, but Debian and Ubuntu has changed their default shell to Dash (in 2006 I think), and embedded systems usually use some lightweight shell such as BusyBox. So far from all systems do.
- TeMPOraL 12y agoThanks for clarification!
- stephenr 12y agoJust to clarify a little: By default Debian still uses Bash for interactive user shells, but since Squeeze (early 2011), /bin/sh is provided by Dash. Dash is used because it's faster than Bash and has less dependencies so its more resilient to failures. for more info see https://wiki.debian.org/Shell https://wiki.debian.org/Shell, https://wiki.debian.org/DashAsBinSh https://wiki.debian.org/DashAsBinSh and https://packages.debian.org/wheezy/dash https://packages.debian.org/wheezy/dash
- dllthomas 12y agoThere is tremendous range in what a "shell script" might be. I vastly prefer bash to sh as a user shell. Often times, I have bits of logic I express in a command that I want to capture and reuse, and they get grabbed and dropped in a (frequently context specific) bin directory. I would contend that these "save me from typing it out" shell scripts should mimic what I would type myself. Once they wind up being more general, I usually rewrite them in a different language entirely. That's a very different context than something like an init script, though.