Re: Bash script variables question[Scanned]

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

 



On 06Aug2006 13:27, Tom Diehl <tdiehl@xxxxxxxxxxxx> wrote:
| >=>Also, just for other scripts, this:
| >=>	foo=`command`
| >=>is more portable than
| >=>	foo=$(command)
| >
| >Never use backquotes when the $( cmd ) is available.

Portable practice presumes $() not to be available.

| The backquotes are
| >deprecated in bash and ksh and are only available in antique Bourne
| >shells. In addition there are subtle differences in quoting between the
| >two.
| 
| Any idea why the authors feel the need to break 20+ years of history? I 
| fail to
| see why foo=`command` is better or worse than foo=$(command). I only have 
| 17+ years worth of sh, ksh, and bash scripts that use the foo=`command` 
| construct.

There's nothing subtle about it. $(...) lets you nest things without quoting
difficulties. The `...` syntax imposes a layer of slosh quoting. $() is
definitely cleaner and easier. But plenty of platforms exist where it is not
supported in /bin/sh. So $() is to be avoided for portable scripts
on the whole.
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Because of its special customs, crossposting between alt.peeves and normal
newsgroups is discouraged.      - Cameron Spitzer


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux