[svlug] Evil Backquotes (was Re: how to copy a bunch of "." files?)

dfox@belvdere.vip.best.com dfox at belvdere.vip.best.com
Sun May 14 11:38:39 PDT 2000


> As far as I know, they're non-standard -- they certainly they don't
> work in many ksh's.  And they're hard for the eye to distinguish from

AFAIK, ksh isn't as widely-used as bash/sh or csh. csh still seems to
be a 'standard' shell -- even some linux people I've known use tcsh
for root, even though that's not distribution-standard. They probably
do that because that's what they're used to: some tradition says root
uses csh/tcsh. I am not very familiar with csh, and backquotes might
not be as useful there either. But one isn't supposed to script with
csh anyway, so that's moot.

Bash is pretty standard at least on Linux, and backquotes work there,
and I suspect they work equally well in other sh-compatible shells, 
which is what people are supposed to script with: in other words, most
of the time, the script is going to begin with '#! /bin/sh', not
'#! /bin/csh' or '#! /bin/ksh', or it'll want to use perl.

> other quotes.  Mix-and-match with backquotes is a nightmare.  And
> finally, they cannot be nested.  Which is a serious and frequently

I agree with you there -- it does make reading difficult. It's simply
a very nice feature, useful in many situations. It's too bad that 
the designers chose the backquote -- quoting in and of itself is not
always clear in shell -- which is one reason I preferred using the back-
quotes in the example I provided: it's cleaner than the find(1) equivalent,
with all its extra quoting and globbing baggage.

> Use $() instead -- it solves all these problems, in a POSIX-compliant,
> ksh-compatible manner.  $(), IMO, makes it much more clear that

Good point. I just haven't become used to doing that, but it does make
sense, and you're right -- it does make the script look clearer, and
easier to distinguish what's happening.

> Just say no to backticks. :-)

Not only that, the ` is sometimes hard to get to on the keyboard :).

> Chris Waters   xtifr at dsp.net | I have a truly elegant proof of the
>       or    xtifr at debian.org | above, but it is too long to fit into
> http://www.dsp.net/xtifr     | this .signature file.
 
------------------------------------------------------------------------
David E. Fox                     Census         Thanks for letting me
dfox at belvdere.vip.best.com        2000          change magnetic patterns
Be Counted: http://www.census.gov               on your hard disk.
-----------------------------------------------------------------------





More information about the svlug mailing list