Re: Does anybody know why Fedora does this?

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

 



On 12.09.2013 02:01, Joe Zeff wrote:
> We all know, I hope, that cd is a built-in function of whatever shell
> you're using.
> 
> [joe@khorlia ~]$ cat /usr/bin/cd
> #!/bin/sh
> builtin cd "$@"
> [joe@khorlia ~]$
> 
> Does anybody know why this file exists?

I'm  not sure but it might be related to, form BASH NOTES file:


    There is a problem with the `makewhatis' script in older (pre-7.0)
    versions of Red Hat Linux.  Running `makewhatis' with bash-2.0 or
    later versions results in error messages like this:

    /usr/sbin/makewhatis: cd: manpath: No such file or directory
    /usr/sbin/makewhatis: manpath/whatis: No such file or directory
    chmod: manpath/whatis: No such file or directory
    /usr/sbin/makewhatis: cd: catpath: No such file or directory
    /usr/sbin/makewhatis: catpath/whatis: No such file or directory
    chmod: catpath/whatis: No such file or directory

    The problem is with `makewhatis'.  Red Hat (and possibly other
    Linux distributors) uses a construct like this in the code:

        eval path=$"$pages"path

    to do indirect variable expansion.  This `happened to work' in
    bash-1.14 and previous versions, but that was more an accident
    of implementation than anything else -- it was never supported
    and certainly is not portable.

    Bash-2.0 has a new feature that gives a new meaning to $"...".
    This is explained more completely in item 1 in the COMPAT file.

    The three lines in the `makewhatis' script that need to be changed
    look like this:

             eval $topath=$"$topath":$name
    [...]
       eval path=$"$pages"path
    [...]
    eval path=$"$pages"path

    The portable way to write this code is

             eval $topath="\$$topath":$name
       eval path="\$$pages"path
    eval path="\$$pages"path

    You could also experiment with another new bash feature: ${!var}.
    This does indirect variable expansion, making the use of eval
    unnecessary.


Mateusz Marzantowicz
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux