Re: [opensuse-factory] Can we assume that /bin/sh is bash?

Hi, On Mon, Feb 18, 2019 at 6:46 PM Martin Wilck <mwilck@suse.com> wrote:
Best, Mischa -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org

Mischa Salle <mischa.salle@gmail.com> wrote:
A script that does not use non-POSIX features and that does not depend on unspecified behavior (another important issue) is called "fully compliant".
That's a joke, dash and ash are not POSIX because they do not support multi-byte characters, which is required unless you are on a tiny embedded system. ash was so buggy that people created dash from ash by fixing bugs. The general idea on why Debian switched to dash seems to be useful. zsh is so far from POSIX that it is not even able to run "configure" in it's default behavior. When switched into it's POSIX mode, it still has noticeable deviations from POSIX. Given that it is as slow as bash, I see nothing that could cause an interest to install zsh as default shell. ksh88 on the other side was the blueprint for the definitions that define the "POSIX shell".
You finally need to test....
So I recommend to try out other shells and to check the current scripts for kshisms and bashisms. It may of course help to firsh use something like "checkbashisms" on scripts that have #!/bin/sh inside or that do not have #! at all. This has been done with Gentoo Linux 2 years ago with pbosh and this helped to identify and fix things that have been related to non-POSIX behavior in pbosh as a result that this shell is a descendent from the original Bourne Shell and the fact that not all differences between Bourne Shell and POSIX shell had been documented before. So my advise is: do it and check whether you have system scripts that depend on non standard behavior. You may have luck and there is few to change. BTW: In 2008, OpenSolaris has been converted to have ksh93 as /bin/sh and several scripts have been changed. I needed to introduce minor changes (mainly to avoid [[ ]]) into three system scripts in order to be able to install pbosh as /bin/sh. Given that this discussion is more than a simple question that ends after someone posted an answer, you should run such a test and fix scripts that include #!/bin/sh but depend on non standard- or on undefined behavior. Jörg -- EMail:joerg@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/' -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org

On Tue, Feb 19, 2019 at 12:28:02PM +0100, Joerg Schilling wrote:
Ouch ... IMHO [[...]] is a major win for a bourne shell. If you're teaching shell syntax there is no nead to mention [...] but only [[...]] with ksh93 and bash. I do not see any advantage to use a minimal set of POSIX bourne shell. Here we have the fully control which bourne shell should be used for /bin/sh. If systems will be ported from an old UNIX system (and IMHO OpenSolaris is old ;) most most scripts will run even if written for minimal POSIX bourne shell. There is no need to use a castrated bourne shell aka minimal POSIX bourne shell on Linux. -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr

"Dr. Werner Fink" <werner@suse.de> wrote:
The advantage of using [[ instead of [ is minimal and you don't really need it as you could write scripts that avoid it. ksh93 has other real advantages that people usually miss and that BTW are just being destroyed by the Redhat people that work on the https://github.com/att/ast/ repository.
Correct, OpenSolaris is a true descendent from the original UNIX Code and as a result, it will be able to look back at 50 years of of UNIX history in August this year. If you look at the kernel, there are many modern concepts inside Solaris, that are still missing in Linux, so what do you understand by "old"?
written for minimal POSIX bourne shell. There is no need to use a castrated bourne shell aka minimal POSIX bourne shell on Linux.
The advantage of using a small but POSIX shell as the default shell (in special if it supports "modern" features like vfork() that are unsupported by bash) is a faster and more robust startup. Even on a true UNIX, there are other shells in addition, but these shells are used after the basic startrup is ready. Finally: /bin/sh is not mentioned in POSIX it is not "the POSIX shell" of a platform, it is just the default shell. In theory, you could install something that stinks like "fish" as /bin/sh if you adjust your scripts and if you follow the official rules for providing a POSIX shell. The POSIX shell is run after you type: PATH=`getconf PATH` sh and typically is in a path like /usr/xpg?/bin/sh Jörg -- EMail:joerg@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/' -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org

Mischa Salle <mischa.salle@gmail.com> wrote:
A script that does not use non-POSIX features and that does not depend on unspecified behavior (another important issue) is called "fully compliant".
That's a joke, dash and ash are not POSIX because they do not support multi-byte characters, which is required unless you are on a tiny embedded system. ash was so buggy that people created dash from ash by fixing bugs. The general idea on why Debian switched to dash seems to be useful. zsh is so far from POSIX that it is not even able to run "configure" in it's default behavior. When switched into it's POSIX mode, it still has noticeable deviations from POSIX. Given that it is as slow as bash, I see nothing that could cause an interest to install zsh as default shell. ksh88 on the other side was the blueprint for the definitions that define the "POSIX shell".
You finally need to test....
So I recommend to try out other shells and to check the current scripts for kshisms and bashisms. It may of course help to firsh use something like "checkbashisms" on scripts that have #!/bin/sh inside or that do not have #! at all. This has been done with Gentoo Linux 2 years ago with pbosh and this helped to identify and fix things that have been related to non-POSIX behavior in pbosh as a result that this shell is a descendent from the original Bourne Shell and the fact that not all differences between Bourne Shell and POSIX shell had been documented before. So my advise is: do it and check whether you have system scripts that depend on non standard behavior. You may have luck and there is few to change. BTW: In 2008, OpenSolaris has been converted to have ksh93 as /bin/sh and several scripts have been changed. I needed to introduce minor changes (mainly to avoid [[ ]]) into three system scripts in order to be able to install pbosh as /bin/sh. Given that this discussion is more than a simple question that ends after someone posted an answer, you should run such a test and fix scripts that include #!/bin/sh but depend on non standard- or on undefined behavior. Jörg -- EMail:joerg@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/' -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org

On Tue, Feb 19, 2019 at 12:28:02PM +0100, Joerg Schilling wrote:
Ouch ... IMHO [[...]] is a major win for a bourne shell. If you're teaching shell syntax there is no nead to mention [...] but only [[...]] with ksh93 and bash. I do not see any advantage to use a minimal set of POSIX bourne shell. Here we have the fully control which bourne shell should be used for /bin/sh. If systems will be ported from an old UNIX system (and IMHO OpenSolaris is old ;) most most scripts will run even if written for minimal POSIX bourne shell. There is no need to use a castrated bourne shell aka minimal POSIX bourne shell on Linux. -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr

"Dr. Werner Fink" <werner@suse.de> wrote:
The advantage of using [[ instead of [ is minimal and you don't really need it as you could write scripts that avoid it. ksh93 has other real advantages that people usually miss and that BTW are just being destroyed by the Redhat people that work on the https://github.com/att/ast/ repository.
Correct, OpenSolaris is a true descendent from the original UNIX Code and as a result, it will be able to look back at 50 years of of UNIX history in August this year. If you look at the kernel, there are many modern concepts inside Solaris, that are still missing in Linux, so what do you understand by "old"?
written for minimal POSIX bourne shell. There is no need to use a castrated bourne shell aka minimal POSIX bourne shell on Linux.
The advantage of using a small but POSIX shell as the default shell (in special if it supports "modern" features like vfork() that are unsupported by bash) is a faster and more robust startup. Even on a true UNIX, there are other shells in addition, but these shells are used after the basic startrup is ready. Finally: /bin/sh is not mentioned in POSIX it is not "the POSIX shell" of a platform, it is just the default shell. In theory, you could install something that stinks like "fish" as /bin/sh if you adjust your scripts and if you follow the official rules for providing a POSIX shell. The POSIX shell is run after you type: PATH=`getconf PATH` sh and typically is in a path like /usr/xpg?/bin/sh Jörg -- EMail:joerg@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/' -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
participants (3)
-
Dr. Werner Fink
-
Joerg Schilling
-
Mischa Salle