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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityThe 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?
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.
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.
/bin/sh
...
Jul 24, 2015 at 7:02
cmd
) in *sh shells been deprecated? and you will find the answer.sh
which in the right environment will support$(...)
.