Re: Bash script variables question[Scanned]

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

 



On Sunday 06 August 2006 14:31, Paul Howarth wrote:
> On Sun, 2006-08-06 at 13:27 -0400, Tom Diehl wrote:
> > 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).

[snip]

> It allows constructs like this:
> 
> $ var=$(foo $(bar))

You mean like this?

    var=`foo \`bar\``

There are restrictions, but that isn't one of them.

    $ sh -c 'var=`echo \`ls .zshrc\``;echo $var'
    .zshrc

The Korn shell manual page does document the restrictions:

     Additionally, the backquoted syntax has historical  restric-
     tions on the contents of the embedded command. While the new
     $() form can process any kind of valid embedded script,  the
     backquoted  form  cannot  handle  some  valid  scripts  that
     include  backquotes.  For  example,  these  otherwise  valid
     embedded scripts do not work in the left column, but do work
     on the right:
     echo `                      | echo $(
     cat <<eeof                  | cat <<eeof
     a here-doc with `           | a here-doc with )
     eof                         | eof
     `                           | )
     echo `                      | echo $(
     echo abc # a comment with ` | echo abc # a comment with )
     `                           | )
     echo `                      | echo $(
     echo '`'                    | echo ')'
     `                           | )

     Because of  these  inconsistent  behaviors,  the  backquoted
     variety  of  command substitution is not recommended for new
     applications that nest command substitutions or  attempt  to
     embed complex scripts.

-- 
Garry T. Williams --- +1 678 656-4579

-- 
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