1

Is the relation between Bourne shell and Bash similar to that of C and C++(if so it would signify that both have their place as a shell)? Whenever I read something about shells it always says that Bourne shell is dead and obsolete, but why?

john
  • 33
  • 4
  • 1
    Could you please explain where you run the Bourne Shell? What OS are you using? – schily Jul 02 '20 at 10:58
  • I'm not sure that I understand the "where" part, but I run it on Arco Linux as an interactive shell in xterm terminal emulator – john Jul 02 '20 at 11:00
  • I was not implying that, rather I thought that if that the case then Bourne shell has it use and place among other shells. – john Jul 02 '20 at 11:21
  • Well, that was the alternative way to read it, I wasn't sure :) – ilkkachu Jul 02 '20 at 11:22
  • Anyway, are you sure it's not Bash you have on your desktop too? It's probably the most common interactive shell on Linuxes (I don't count android), though Zsh probably gets some love too. See what getent passwd $USER | cut -d: -f7 says? – ilkkachu Jul 02 '20 at 11:23
  • I would be cautious about the C / C++ analogy. C and C++ are designed for two completely different idioms in programming and, though one did arise from the other they should no longer be considered similar. – Philip Couling Jul 02 '20 at 11:32
  • my shell is /bin/sh , and in my /etc/shells is also dash(so unless dash has two different names I'm not using dash), my default shell was Bash and then I set it to sh. I think that it has to be the Bourne shell, given that the only other option that could be labelled as sh is Thompson shell and it has a different syntax with which my shell procedures would not work. – john Jul 02 '20 at 11:37
  • See my hint on whatshell in my answer... – schily Jul 02 '20 at 12:10
  • okay now I am confused, I ran whatshell and it spits out bash 5.0.17(1)-release . Weird considering that it doesn't use my .bashrc . If /bin/sh is Bash then why is there also /bin/bash ? Sorry if my understanding of thing is flawed or lacking. – john Jul 02 '20 at 12:33
  • .bashrc is only run for login shells. Maybe you GUI is not designed to make the shells in a terminal window a login shell as expected. – schily Jul 02 '20 at 12:55
  • 1
    @john, Your /bin/sh may well be Bash. It is in many Linux distributions, if not "most". Possibly just a copy or a link, but in any case. Debian and Ubuntu are the usual exception, with Dash as /bin/sh. Run echo $BASH_VERSION in your interactive shell; if it prints anything, it is Bash. Also perhaps ls -li /bin/sh /bin/bash. – ilkkachu Jul 02 '20 at 17:24

1 Answers1

2

It is most unlikely that you really use the Bourne Shell it is more likely that you are using dash (The Debian Almquist Shell). You may like to check this by calling:

echo $0

The exact name of the shell may be retrieved via the whatshell script from https://www.in-ulm.de/~mascheck/various/whatshell/

But dash is not the Bourne Shell and with respect to UNIX worse than the Bourne Shell as dash does not support multi-byte characters.

The Bourne Shell is a shell that has been started as a rewritten Thompson Shell by Stephen Bourne in 1976 and since then has evolved massively.

In 1983, a copy of the Bourne Shell was used as the starter for the Korn Shell (ksh) by David Korn.

In 1988, both Bourne Shell and ksh did get support for internationalization and the libc from UNIX evolved until 1992, so that both since then support multi-byte characters.

In 1989, the Korn Shell has been used as a paragon for Bash, the GNU project's shell.

In 1989, the Bourne Shell from 1982 has been used as a paragon for ash (the Almquist shell) and dash is a bug-fixed version of ash. But both ash and dash later added POSIX features.

In 1992, POSIX used ksh88 as a paragon for the POSIX shell definitions.

In 2005, OpenSolaris made the Bourne Shell open source and starting from 2006, the Bourne Shell source code evolved to become POSIX compliant.

While dash misses a history editor and multi-byte support, the current Bourne Shell implements these features.

The main differences between shells today are however (besides POSIX compliance) features that make the shells nice to use as interactive shells. This is what you get from a recent Bourne Shell (bosh), from ksh and from Bash, but not from dash.

ilkkachu
  • 138,973
schily
  • 19,173
  • 5
    Would you mind not using code tags for key words and names. Please reserve code tags for actual code and artefacts from code (eg: commands). It makes your answer very tiring to read. (as discussed here) – Philip Couling Jul 02 '20 at 11:33
  • 1
    dash has a line editor (via libedit like most ash descendants), but it's usually disabled at compile time as dash is only intended for /bin/sh as the system shell to interpret POSIX shell scripts or be used in system(), popen()... That's the sh interpreted there, not intended as an interactive shell. – Stéphane Chazelas Jul 02 '20 at 12:13
  • 2
    Note that in the Bourne Shell sourcecode evolved to become POSIX compliant, schily is refering to bosh part of schily-tools. It is indeed based on code from the Bourne shell (though it's a bit of a stretch to call it the Bourne shell), and has indeed a few advantages over dash, though at this time, it's unlikely anyone will have come across it on production system. – Stéphane Chazelas Jul 02 '20 at 12:16
  • @StéphaneChazelas since it still compiles as obosh (to be 100% Bourne Shell compatible) from the same source (via #ifdefs) I see no reason not to call itBourne Shell. On the other side, the size of the source code is now 4x the size it has been in 2005. – schily Jul 02 '20 at 12:57
  • I edited out most of the code blocks (as I did with the question too), since really, something like "Korn shell" is just a name for humans, not computer code. Though I'm not sure how dash should be spelled, the Debian docs seem to use both "dash" and "Dash" for it... – ilkkachu Jul 02 '20 at 17:45