Backtick versus $()

Thorsten Glaser tg at
Thu Feb 24 20:10:07 UTC 2011

Andres Perera <andres.p <at>> writes:

> > Nowadays all shells supports $() so I advise you to use it :).
> no, not all shells support $()

They do, it’s mandated by POSIX. There’s no reason to support the
accidentally non-combining accent gravis (so-called “backtick”¹)
any more, unless you specifically target Solaris 10 and below’s
/bin/sh (which always had a ksh and /usr/xpg4/bin/sh which both
are POSIX compatible), or, worse, the Bourne shell (you know, the
one where you wrote ^ instead of | for pipes).

Warren Block <wblock <at>> writes:

> Still: aren't backticks and $() supposed to be equivalent?

Nope. The so-called backtick is deprecated, doesn’t support nesting,
and quoting (`…"…"…`) is Undefined, both with or without backslashes
in front of the (inner) double quotes. And there may be more.

① explains quite
well why a “backtick” doesn’t exist and the accident behind this
ASCII character / codepoint. In short: never use it period.

FWIW, I'm quite impressed with mksh interactively. I thought it was much
*much* more bare bones. But it turns out it beats the living hell out of
ksh93 in that respect. I'd even consider it for my daily use if I hadn't
wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh

More information about the freebsd-questions mailing list