Skip to main content
1 of 3
Michael Ekstrand
  • 2.2k
  • 3
  • 21
  • 24

Any reason to use or teach `…` substition for new development?

It is my understanding that the more modern $(...) command substitution syntax is preferred over the old '`'-based syntax, due to easier and less error-prone nesting and escaping syntax.

Further, it seems that most /bin/sh-style shells in modern use support $(…):

  • bash
  • ash (and therefore BusyBox, so most embedded Linux)
  • dash
  • FreeBSD /bin/sh

And $(…) is specified by IEEE 1003.1.

So I have 2 very related questions:

  • Is there any reason to use ` in new development of shell scripts unless you know of a specific old system that the script will need to run on?
  • Is there any reason not to teach UNIX programming students just to write $(...), and discuss ` only as an obsolete variant that they will likely encounter if they are reading other developers' shell scripts (and may need if they are working with a really old system or nonstandard for some reason)?
Michael Ekstrand
  • 2.2k
  • 3
  • 21
  • 24