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

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux