Public bug reported:

Binary package hint: bash

lsb_release -rd   
    Description:    Ubuntu 9.04
    Release:        9.04
------------------------------------------
apt-cache policy bash
bash:
  Installed: 3.2-5ubuntu1
  Candidate: 3.2-5ubuntu1
  Version table:
 *** 3.2-5ubuntu1 0
        500 http://us.archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status
---------------------------------------------

What I expected:
I set an alias for 'ls' using the ~/.bash_aliases file but the alias was being 
overridden and therefore failing to work as expected. No matter what I put into 
the .bash_aliases file, it was being overridden to "ls=ls --color=auto".

What I found:
In the file ~/.bashrc, the call to  ~/.bash_aliases  is before setting the 
alias "ls=ls --color=auto". The order of these steps is an error as the 
.bash_aliases file should override any and all system-set aliases. 

Recommended fix:
+++  Modify the file /etc/skel/.bashrc from the following

----cut-----
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases
#fi

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi
----cut----

+++ Change to the following:

----cut----
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
----cut----

Putting the call to ~/.bash_aliases after setting the 'ls' alias allows
the user to override the alias to 'ls' as they see fit. Given that 'ls'
is a heavily used command it is also highly likely to be modified using
an alias.

Not really another bug, but while we are fixing minor bugs... Why is the
call to ~/.bash_aliases commented out by default? I see no issues in un-
commenting the call to ~/.bash_aliases in .bashrc by default thereby
saving admin's the step of un-commenting it themselves.

Attached is the modified file intended to replace /etc/skel/.bashrc. I
see no point in submitting a patch for a 100-line text file, so this was
the easy route.

** Affects: bash (Ubuntu)
     Importance: Undecided
         Status: New

-- 
bash aliases for 'ls' in ~/.bash_aliases file overridden by ~/.bashrc
https://bugs.launchpad.net/bugs/400686
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to