If bash is started with the --posix flag it simplifies it's behaviour to conform to POSIX standards. Since the sh is way simpler than bash it also is faster. I was thinking that /bin/sh could be a simple wrapper for calling bash with this single argument. This would be a depless speed improvement! From what I can see most of the packages work with a simple posix sh and running a dash system I recall having around 3 problems in the last year, which were fixed quickly. I have opened this bug in "new packages" category because I think adding this could be solved by another package, maybe called `bash-posix` that could be later added to app-alternatives/sh.
I guess that would mean a compiled wrapper, since you don't want /bin/sh to run via shell.
(In reply to Filip Kobierski from comment #0) > Since the sh is way simpler than bash it also is faster. > I was thinking that /bin/sh could be a simple wrapper for calling bash with > this single argument. This would be a depless speed improvement! This sounds unlikely to me. Do you have any evidence of this speed improvement?
While looking for answers to Mike's question I have made a good discovery: It turns out that: "When invoked as sh, Bash enters POSIX mode after reading the startup files." (https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html) My tests confirm that: TEST 1: point 15 $ cat test.sh 0myfn() { echo foo; }; type 0myfn $ bash ./test.sh 0myfn is a function 0myfn () { echo foo } $ sh ./test.sh ./test.sh: line 2: `0myfn': not a valid identifier $ dash ./test.sh ./test.sh: 2: Syntax error: Bad function name TEST 2: accepting `function`: $ cat test.sh function myfn { echo foo; }; type myfn $ bash ./test.sh myfn is a function myfn () { echo foo } $ sh ./test.sh myfn is a function myfn () { echo foo } $ dash ./test.sh ./test.sh: 2: Syntax error: "}" unexpected TEST 3: point 15 (not clear but exhibits different behaviour) $ cat test.sh [ -n $BASH ] && echo posix? $POSIXLY_CORRECT myfn() { echo foo; }; type myfn $ bash ./test.sh posix? myfn is a function myfn () { echo foo } $ sh ./test.sh posix? y myfn is a function myfn () { echo foo } $ dash ./test.sh posix? myfn is a shell function This makes this proposal useless, as it is the default bash behaviour already.