9

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?

joeytwiddle
  • 1,018
  • 9
  • 15

2 Answers2

8

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.

Thomas Dickey
  • 76,765
5

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.

maxschlepzig
  • 57,532
  • 2
    @cuonglm, yes, I just tested it and I can confirm it. Would have thought that rather Hurd is going to be released than Sun/Oracle changes its policy on /bin/sh ... – maxschlepzig Jul 24 '15 at 07:02