Bourne to Bourne Again Shell Forward Compatibility

Bourne Shell

Developed by Stephen Bourne at Bell Labs and released 1979 as a replacement for the earlier Thompson Shell, Bourne Shell was the default shell of Version 7 of AT&T UNIX. It was introduced by its manual as „command language“, and it features control structures for conditional and repetitive execution. It enables the user to implement algorithms that perform non-interactive tasks such as the orchestration of batch processes or accumulating long-term reporting data. The same executable provides an interactive mode in which it reads commands from a user in realtime and replies to them with status and error messages as well as the output of executed programs.

With the advent of the „Shebang“ convention, letting text files state the executable they should be interpreted with, Bourne Shell scripts have conventionally been headlined as follows:

#!/bin/sh

Over the course of many years, the software has undergone several forks and diversions.

As a case study, consider IBM AIX version 7:

  • A version of Korn Shell (ksh) will by default be set up as what is called the „default shell“, set up at a location /usr/bin/sh.
  • /bin is a symlink to /usr/bin, so the #!/bin/sh convention will work.
  • The default shell can be changed; the documentation specifically states that a „Bourne Shell interpreter“ (bsh) can also be linked to by sh. By changing this setting, every script that uses #!/bin/sh would be interpreted in Bourne instead of Korn Shell.
  • A variant refered to as „POSIX shell“ will be available as executable psh, which in turn is a link to sh.
  • The version of ksh installed by default will be „88“, but a newer version „93“ is available, too.
  • There is also the system-wide setting of a „default (operating system) login shell“ which is set to /usr/bin/sh, again, really a link to ksh, which can be changed as well, which is a different setting that that of the default shell: What is the default shell is decided by what the symlink /usr/bin/sh points to, while the setting of default login shell will govern what login shell will be assigned to newly created users.

For the official explanations see

It is noteworthy that all interpreters mentioned above (POSIX-, both versions of Korn Shell and the Bourne Shell interpreter) claim to be „compatible to Bourne Shell“. However, the amount of variants and possible choices on a single UNIX implementation alone suggests that they are either not equivalent or unable to stand in for one another without friction. Each one of them has to be required by a significant amount of users, justifying its maintenance effort as part of the commercial product „AIX“.