Skip to main content
edited title
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

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

code markup for the inline backticks
Source Link
Barmar
  • 10.6k
  • 1
  • 22
  • 29

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)?

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)?

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)?
Tweeted twitter.com/#!/StackUnix/status/558087684066140160
Source Link
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)?