Which shells don't support dollar-parenthesis expansion, and demand backticks?

The modern recommendation is to use:

$(...)

instead of the older:

`...`

mainly for readability and to avoid the need for escaping when nesting.

Which shells do not support the $(...) form, and are any of them still in use today?

Asked By: joeytwiddle

||

The original Bourne shell, csh or tcsh all do not support $() and require `` for command substitution.

The Bourne shell is no longer used as the default shell (/bin/sh) on many UNIX based operating systems. However, these shells are still supplied by the OS vendors as they are still used for historical reasons.

Both AIX and HP-UX have /bin/sh as a POSIX compliant shell. Bourne shell is still available on AIX as ‘bsh’ (but deprecated in 1995 with AIX 4.1) and HP-UX 11.11 ‘/usr/old/bin/sh’ (Bourne was removed from 11.23). I’m not sure when the switch was made, but it was many years ago.

Answered By: user14755

The Solaris 10 and earlier /bin/sh does not support $().

It is still in use today because Solaris 10 is still in use, Sun did not want to replace it with a standard conforming version (up to and including Solaris 10) – and because most people consider /bin/sh as the default shell and don’t know how to portably execute a script with a POSIX conforming shell.

Sun’s motivation for not changing /bin/sh was to avoid breaking existing shell scripts that rely on the non-conforming behavior.

Answered By: maxschlepzig