Timeline for Is there any reason to have a shebang pointing at /bin/sh rather than /bin/bash?
Current License: CC BY-SA 3.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 29, 2015 at 17:01 | comment | added | user121183 | @Sobrique Consider tagging next time so the person can get notification ;) | |
| Dec 24, 2015 at 9:34 | comment | added | Wildcard | @DietrichEpp, those scripts were definitely incorrect, as sixtyfootersdude points out. I feel @Marco's answer unfortunately de-emphasizes testing for portability before using #!/bin/sh. "Simple scripts" may not require bash, as he says in point 3, but if you didn't test your script with anything but bash, you shouldn't be using #!/bin/sh. | |
| Dec 23, 2015 at 21:47 | comment | added | Wayne Werner | Also busybox and alpine linux which are much lighter weight than their counterparts. | |
| Dec 23, 2015 at 9:55 | comment | added | schily | Well, I did some test with a similar command before (shell -c ':') and even on a 10 year old machine, I get something around 2ms per Bourne Shell call (dash is a bit faster) and 4ms for ksh93, but yash is even slower than ksh93 and times in that magnitude are not a problem - in special as /bin/echo (6kB) needs 1.5ms. | |
| Dec 23, 2015 at 8:52 | comment | added | Blacklight Shining | @schily time $shell -c '' seems to me like a good way of measuring the time a shell takes to start and to exit. | |
| Dec 22, 2015 at 23:28 | comment | added | Dietrich Epp | @atamanroman: The scripts were incorrect in the first place, they should have used #!/bin/bash if they wanted Bash (nothing wrong with that!). The change was mostly done upstream in Debian. It improved user experience, it had a measurable impact on system startup time. It also positively impacted security, see "Shellshock". | |
| Dec 22, 2015 at 18:58 | comment | added | atamanroman | Quite a few scripts assume that /bin/sh is /bin/bash. Ubuntu switching from bash to dash broke all of them. | |
| Dec 22, 2015 at 17:33 | comment | added | schily | How do you measure start up time and what values do you get? | |
| Dec 22, 2015 at 17:12 | comment | added | Stéphane Chazelas | @schily, that depends a lot on the script. For instance ksh93 startup time is quite bad on Linux (on par with bash, not as bad as zsh), so not a very good choice for /bin/sh that is used for system(), popen() or other one-line simple commands and short and simple scripts. pdksh and derivatives can also beat dash or ksh93 on some things. | |
| Dec 22, 2015 at 16:45 | comment | added | schily | @Stéphane Chazelas The fastest shell for scripting is ksh93, followed by the Schily Bourne Shell and directly followed by dash. dash is however only fast because there is no multi-byte character support in dash. | |
| Dec 22, 2015 at 16:09 | comment | added | Sobrique | No. Some OS link it, because bash is backwards compatible. | |
| Dec 22, 2015 at 15:59 | vote | accept | Jules | ||
| Dec 22, 2015 at 15:55 | comment | added | user121183 | Isn't /bin/sh just a symlink to the default shell? | |
| Dec 22, 2015 at 15:36 | comment | added | Stéphane Chazelas | @derobert, /bin/sh is faster if it's not bash, there still are a few systems like OS/X or RHEL where /bin/sh is bash. | |
| Dec 22, 2015 at 15:11 | comment | added | derobert | Another reason: often /bin/sh is faster than bash, or at least loads quicker (due to being smaller). | |
| Dec 22, 2015 at 14:02 | history | answered | Marco | CC BY-SA 3.0 |