PATH has /bin before /usr/bin in upgraded rawhide

Ben Boeckel mathstuf at gmail.com
Mon Oct 28 14:02:18 UTC 2013


On Mon, 28 Oct, 2013 at 11:02:56 GMT, Sandro Mani wrote:
> The odd thing I didn't notice before is that on a VT, also on the 
> newrawhide machine (as non-root user) I get 
> /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/$HOME/.local/bin:$HOME/bin. 
> But from a GUI terminal, /bin and /usr/bin are in inverted order (i.e. 
> /usr/bin before /bin, as expected). Can anyone else reproduce this?

I'm able to reproduce the error on my Rawhide box (last installed as
Fedora 18/Rawhide in July 2012) on a TTY:

    $ echo $PATH
    /usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/boeckb/.cabal/bin

My bashrc fixes it to:

    % echo $PATH
    /home/boeckb/.local/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/boeckb/.cabal/bin:/home/boeckb/bin

The code which does this:

    # Fix PATH
    _fix_path () {
        local old_path
        local tr
        local readlink

        old_path="$PATH"
        tr="$( which tr )"
        readlink="$( which readlink )"

        PATH="$HOME/.local/bin"

        for p in $( echo "$old_path" | "$tr" ":" " " ); do
            [ -d "$p" ] && \
            #[ "$p" = "${p#/usr/local}" ] && \
            [ -z "$( "$readlink" "$p" )" ] && \
                PATH="$PATH${PATH:+:}$p"
        done

        export PATH
    }

    _fix_path

    unset _fix_path

Not sure where $HOME/bin comes from. And yeah, I put $HOME/.local/bin
first. I have wrapper scripts which trampoline a few things and link to
my local install root (~/misc/root/$pkg) for local versions of things
like task, mpv, sometimes git, and others).

--Ben



More information about the devel mailing list