Bourne | Ash |  #!  | find | ARG_MAX | Shells | whatshell | portability | permissions | UUOC | ancient | - | ../Various | HOME
"$@" | echo/printf | set -e | test | tty defs | tty chars | $() vs ) | IFS | using siginfo | nanosleep | line charset | locale


What shell is this?

2011-11-12 .. 2022-01-04 (see recent changes)

Here is a script which tries to determine the very version for all bourne and bourne-compatible shells.

 $ shell whatshell.sh # and a version with explaining comments inline

(and a direct link to the script)

Why? The traditional Bourne shells and the Almquist shells don't provide any version information at all.
In these shells, you have to test for features and bugs to find out what you are actually running
For Almquist Shells from a distribution package, the package information usually helps.
But this is non-trivial from the perspective of portable determination, let alone buysbox ash.

Earlier Korn shells (ksh86, ksh88) reveal their versions only in interactive mode.

I haven't put more than basic effort into verifying shells which provide a version variable.

Again: why? Well, for fun, and out of curiosity. I'd like to hear from you about shells and systems.
And certainly about anything which fools the script.

The script currently understands:

The script avoids system commands. The only exception is echo, if not built into the shell. uname is not consulted.
The script doesn't need file system access, except for redirections to /dev/null.
The detection is based on heuristics, checks might not be too robust, and the script might stumble about shells which it hasn't seen until now.

Issues:
- it is too long
- fails to detect Schily sh variants before 2012-04-07 on some Linux/glibc systems (the shell crashes due to memory allocation issues)
- fails to detect Busybox 0.52 (at least what I had compiled from it once upon a time)
- several later posh releases (~0.8-0.10) don't have their version compiled in
- several early posh releases (before 0.5) seem to have their version number out of date
- Am I a bit late? Heck, yes. This script would have been so much more fun around 1995-2000.

Loop over it if you like, e.g. along these lines,

  UNAME=`uname -sr`
  for i in /bin/*sh /usr/local/bin/*sh /sbin/*sh; do
    case $i in *r*sh|*csh|*ssh) continue;;esac 
    echo "$i ($UNAME): `$i ./whatshell.sh 2>&1`"
  done

See also an overview about unix system shells.

This script was inspired by earlier scripts called "whichshell" from Brian Hiles (~'96/'98)
and which_interpreter from Stéphane Chazelas (~'04). These scripts emphasized on
detecting more shell families, like csh, or even various interpreter languages.

I used Stéphane's "typeset -Z2" check to identify ksh88 (and actually ksh86, too), thanks.


What interpreter is this?

In fact, Stéphane's which_interpreter is modular and can be combined with the bourne-only whatshell.sh!

 $ shell which_interpreter_ext # (link shows the script as page, here is a link to the script)


Example output

(results from whatshell.sh, and some additional notes appended)


Shells without version variables:

earlier Korn shells

  whatshell output:                                     # information about system called on:

  ksh86 Version 06/03/86(/a) 				# ksh86a compiled on EP/IX 2.2.1AA, Ultrix 4.5
  ksh88 Version (..-)11/16/88 				# /bin/ksh (1st ksh88 release) on Ultrix 4.5
  ksh88 Version (..-)11/16/88d  			# /bin/ksh "11/16/88d SBCS" on EP/IX2.2.1AA and "M-11/16/88d" on AIX 3.2
  ksh88 Version (..-)11/16/88e 	 			# /bin/ksh on IRIX 4.0.5
  ksh88 Version (..-)11/16/88f 	 			# /bin/ksh on OSF1/V4b, /bin/sh on IRIX 6.5 and on AIX 5.1 (thanks to Michael Baeuerle)
  ksh88 Version (..-)11/16/88f 	 			# /bin/sh "M-11/16/88f-beta4" on IRIX 5.3 (thanks to Vaxima)
  ksh88 Version (..-)11/16/88g 	 			# /bin/ksh on OSR506, on SVR4.2, /OpenServer/bin/ksh on UnixWare 7.1.4
  ksh88 Version (..-)11/16/88h 	 			# /bin/xksh on UnixWare 7.1.4
  ksh88 Version (..-)11/16/88h 	 			# /usr/bin/euc/ksh on OSR506: versioned as 88g, but it has some bugs fixed
  ksh88 Version (..-)11/16/88i				# /usr/bin/ksh on SunOS 5
  ksh88 Version (..-)11/16/88i (posix octal base)	# /usr/xpg4/bin/sh on SunOS 5

Bourne shells

  7th edition Bourne shell				# /bin/sh on Unix 7th edition (simh)
  7th edition Bourne shell, # comments (BSD, or port)	# /bin/sh on Ultrix 4.5, current port of 7th ed by Geoff Collyer
  7th edition Bourne shell, # comments (BSD, or port) \
   (and pipe check for Bourne shell failed)		# current port of 7th ed shell by Nikola Vladov
 
  System III Bourne shell				# /bin/sh on System III (simh)
 
  SVR1 Bourne shell					# SVR1 shell, compiled on a System III
 
  SVR2 Bourne shell					# /bin/sh5 on Ultrix 4.5
  SVR2 Bourne shell					# /bin/sh on OSF1/V4b (personal alpha)
  SVR2 Bourne shell					# oash on OSR506, see scosh(C)
  8th edition (SVR2) Bourne shell \
   (and pipe check for Bourne shell failed)		# 8th ed shell compiled on a System III
 
  SVR3 Bourne shell					# /bin/sh on SunOS 4.1.3, SCO OSR 5.0.x, IRIX 4.0.5
  SVR3 Bourne shell (but getopts built-in is missing)	# oash on SCO OSR507, see scosh(C)
  SVR3 Bourne shell					# /OpenServer/bin/sh on UnixWare 7.1.4

  SVR4 Bourne shell					# /bin/sh on SVR4.0v21 (bochs), and optional SysV sh on OSF1/V4b
  SVR4 Bourne shell (SunOS 5 variant)			# /bin/sh on SunOS 5.3, SunOS 5.10
  SVR4 Bourne shell (SunOS 5 heirloom variant)		# Heirloom sh (derived from SunOS 5)
  SVR4 Bourne shell (SunOS 5 schily variant, before 2016-02-02)                   # Schily sh (derived from SunOS 5)
  SVR4 Bourne shell (SunOS 5 schily variant, since 2016-02-02, before 2016-05-24) # Schily sh, also implements $()
  SVR4 Bourne shell (SunOS 5 schily variant, posix compatible, since 2016-05-24)  # Schily sh, also implements $() and $(()), posix compatible
  SVR4 Bourne shell (SunOS 5 schily variant, since 2016-08-08, in posix mode)     # Schily sh, in strict posix mode
  SVR4.x Bourne shell (between 4.0 and 4.2)		# /bin/sh on EP/IX 2.2.1AA, /bin/bsh on IRIX 5.3 (thanks to Vaxima) and 6.5.5
  SVR4.2 MP2 Bourne shell				# /bin/sh on UnixWare 7.1.4

Almquist shells

  original ash						# original distribution tweaked and compiled on current Debian and SunOS 5
  early ash (4.3BSD, 386BSD 0.0-p0.2.3/NetBSD 0.8)	# /bin/sh on 4.3 BSD (tweaked&compiled)
  early ash (ash-0.2 port, Slackware 2.1-8.0, \
		386BSD p0.2.4, NetBSD 0.9)		# Slackware binary, and as compiled on current Debian, and earliest Cygwin B19 sh
							# /bin/sh on 386BSDp0.2.4 (qemu) and NetBSD 0.9 (bochs)
  early ash (Minix 2.x-3.1.2)				# Minix 2.0.4 and 3.1.0 
  early ash (4.4BSD Alpha)				# /bin/sh on 4.4 BSD Alpha (tweaked&compiled)
  early ash (4.4BSD)					# /bin/sh on 4.4 BSD (tweaked&compiled)
  early ash (4.4BSD Lite, early NetBSD 1.x, BSD/OS 2.x)	# /bin/sh on 4.4BSD-Lite, and on NetBSD 1.0/1.1 (tweaked&compiled)
  early ash (4.4BSD Lite2, BSD/OS 3 ff)			# /bin/sh on 4.4BSD-Lite2 (tweaked&compiled)
 
  ash (Busybox 0.x)					# BusyBox sh 0.53pre2, 0.60.4
  ash (Busybox 1.x)					# BusyBox sh 1.00-pre101, 1.18.4, and interestingly VMWare ESX 6.7.0 /bin/sh
 
  ash (dash 0.3-1 - 0.3.7-10, NetBSD 1.2 - 3.1/4.0)	# ash-0.3.4-2 (Debian Hamm), ash-0.3.4-6 (Slink), ash-0.3.5-11 (Potato)
  ash (dash 0.3-1 - 0.3.7-10, NetBSD 1.2 - 3.1/4.0)	# /bin/sh NetBSD 2.1
  ash (Slackware 8.1 ff, dash 0.3.7-11 - 0.3.7-14)	# Slackware /bin/sh
  ash (NetBSD 3.1-/4.0-)				# /bin/sh on NetBSD 5.1
  ash (dash 0.3.8-30 - 0.4.6)				# Adamantix ash-0.3.8-37.3-adamantix104, dash-0.4.6
  ash (dash 0.4.7 - 0.4.25)				# dash-0.4.8, dash-0.4.25
  ash (dash 0.4.26 - 0.5.2)				# dash-0.4.26, dash-0.5.1
  ash (dash 0.5.3 - 0.5.5)				# dash-0.5.3, 0.5.4
  ash (dash 0.5.5.1 ff)					# dash-0.5.5.1, 0.5.6.1
 
  ash (FreeBSD, Cygwin pre-1.7, Minix 3.1.3 ff)		# /bin/sh on FreeBSD 7.1, and on Minix 3.1.8


And for a quick glance: actual output about some shells with version variable
  bash 1.05.1						# quite an early one (successfully compiled after tweaking on a current Debian)
  bash 1.14.0(1)					# early, too (compiled after some tweaking on SunOS 5.9)
  bash 1.14.0(2)					# ...with build counter, increases when compiling again without make clean
  bash 2.00.0(1)-release				# now with suffix string
  bash 2.05b.0(1)-release 				# the last 2.x
  bash 4.0.0(1)-rc1 					# a release candidate
  bash 4.0.0(1)-release 				# an official release.  no difference if compiled in posix mode.
 
  ksh93 Version M-12/28/93d (dtksh/CDE variant)		# dtksh on SunOS 5, and on UnixWare 7.1.4
  ksh93 Version M-12/28/93e-SCO				# /bin/ksh UnixWare 7.1.4
  ksh93 Version 1993-12-28 k+				# from kornshell.com, naming changed, a + sign: another release with small fixes
  ksh93 Version M 93s+ 2008-01-31			# naming changed again, now with actual release date
  ksh93 Version JMP 93t+ 2009-05-01			# several different dates for a letter possible
  ksh93 Version JM 93t+ 2010-03-05			# different dates for same letter (here t) possible.
							# See the end of this page for the meaning of the letters J, M, P, etc.
 
  @(#)PD KSH v5.1.3 94/12/22				# compiled on SunOS 5
  @(#)PD KSH v5.2.14 99/07/13.2				# /bin/ksh on NetBSD 5.1, latest pdksh
 
  @(#)MIRBSD KSH R24 2005/07/07				# it's apparent, that it's a modern relative of pdksh
  @(#)MIRBSD KSH R35 2008/07/18
 
  posh 0.2.38, possibly slightly newer, yet<0.5		# posh-0.3.7
  posh 0.3.18, possibly slightly newer, yet<0.5		# posh-0.4.4
  posh 0.5.4						# posh-0.5.4, no difference if compiled in posix mode
  posh 0.8.4
  posh POSH_VERSION					# posh-0.8.5, something went wrong when compiling in the version?
  posh POSH_VERSION					# posh-0.10
 
  yash 2.29						# yash.sourceforge.jp
 
  zsh 2.5.03						# compiled on SunOS 5
  zsh 3.0.8						# optional /usr/bin/zsh on a SunOS 5


Comments to Sven Mascheck <mascheck@in-ulm.de>
<http://www.in-ulm.de/~mascheck/various/whatshell/>