[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

About backquotes in shell scripts



Hi,

This is just a short message on why I don't like backquotes in shell
scripts and always use the $(ls blabla) construct instead of `ls blabla`
(since I changed some of them in the lmodern maintainer scripts among my
"cosmetic fixes").

  1. The rules with the $(...) form are much simpler (cf. SUSv3 at
     http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03);
     for instance, they can be naturally nested whereas nested
     backquotes must be escaped.

  2. $(...) is a well-thought syntax:
       - the "$" means "expansion of", just as "$VARIABLE" means "the
         expansion of VARIABLE";
       - there is an opening delimiter and the matching closing
         delimiter.

  3. I read somewhere on Usenet that the backquoted form should have
     been deprecated in favor of the $(...) form. It is just impossible
     to do because too many scripts use backquotes.

That's all. Sure, backquotes are not the end of the world, but it would
be nice if you could avoid them when commiting to lmodern, to make me
happy. :)

Thanks!

PS: another thing that I "fixed" in SVN: when writing comments in
    Makefiles (e.g. debian/rules) among the commands that update a
    target, I indent them with spaces, not with a tab. Otherwise, Emacs
    is not happy and displays the tab in pink, and that sure looks ugly!

So long for my petty habits...

-- 
Florent



Reply to: