bash aliases for 'ls' in ~/.bash_aliases file overridden by ~/.bashrc
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
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://
100 /var/lib/
-------
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/
#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/
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.
This bug was fixed in the package bash - 4.0-4ubuntu1
---------------
bash (4.0-4ubuntu1) karmic; urgency=low
* Merge with Debian; remaining changes:
- Build from the upstream sources, build the documentation in info format.
- /etc/skel/.bashrc: eval lesspipe.
* Changes to the skeleton .bashrc:
- Source .bash_aliases after defining aliases. LP: #400686.
- Enable color support for grep. LP: #386502.
* The bash docs now describe uname -s not having any effect on many
systems. LP: #378595.
* Don't ship an info dir file. LP: #358932.
* Fix some lintian warnings.
bash (4.0-4) unstable; urgency=low
* Apply upstream patches 024 - 028.
- patch 028 closes: #519165. bash-4.0 reverted to the historical
shell behavior of raising an error when $@ or $* was expanded
after `set -u' had been executed and there were no positional
parameters. The Posix working group has since clarified the
standard's position on the issue, and $@ and $* are now the only
variables, parameters, or special parameters that do not raise an
error when unset if set -u is enabled.
* Enable net redirections, now that bash isn't the default shell
anymore. LP: #215034.
* Changes to the skeleton .bashrc:
- Fix example lines in /etc/bash.bashrc to enable bash completion.
Closes: #523706, #522857.
- Don't export HISTCONTROL in bashrc. Closes: #540371.
- Support user dircolors settings in ~/.dircolors. Closes: #506213.
bash (4.0-3) experimental; urgency=low
* Apply upstream patches 011 - 024.
bash (4.0-2) experimental; urgency=low
* Apply upstream patches 001 - 010. Closes: #518289.
* Fix insecure temp file handling in examples scripts. Closes: #509279.
* /etc/skel.bashrc: Only source bash_completion, if posix mode is turned
off. Closes: #498474.
bash (4.0-1ubuntu1) jaunty; urgency=low
* Merge with Debian; remaining changes:
- Build from the upstream sources, build the documentation in info format.
- /etc/skel/.bashrc: eval lesspipe.
bash (4.0-1) experimental; urgency=low
* New upstream version 4.0.
bash (4.0-0ubuntu1) jaunty; urgency=low
* New upstream version 4.0 beta.
-- Matthias Klose <email address hidden> Mon, 24 Aug 2009 12:06:59 +0200