Setting the root password, (bash_completion <-> sudo)
Paul Sladen
sounder at paul.sladen.org
Fri Sep 17 19:06:40 UTC 2004
On Fri, 17 Sep 2004, [ISO-8859-1] Fábio Macêdo Mendes wrote:
> Paul Sladen wrote:
> > I have bash_completion turned on for sudo and the like;
> we can make sudo be a script that points to the real sudo and program
> bash programable completion in /etc/bash_completion or
> /etc/bash_completion.d/ to complete commands that would be in sbin
> paths. The sudo script is very simple:
Don't understand quite would you mean---and I'm not quite sure why it would
help. The sudo/fakeroot completion code already exists and is reliable.
It can be enabled by uncommenting the following lines:
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
In either:
~/.bashrc or /etc/bash.bashrc
The code itself is implemented in:
/etc/bash_completion
Specifically the functions:
# A meta-command completion function for commands like sudo(8), which need to
# first complete on a command, then complete according to that command's own
# completion definition - currently not quite foolproof (e.g. mount and umount
# don't work properly), but still quite useful
#
_command()
{
...
}
To deal with this, the completion is called with the new PATH contain */sbin:
_root_command()
{
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin _command $1
}
complete -F _root_command $filenames sudo fakeroot
which setups up the the `sudo' and `fakeroot' commands lines to be
re-evaluated after having their first item removed (eg. "sudo "). The
completion from the point done on the new, expanded path (including /sbin).
I believe it would be useful to have this enabled on a system-wide basis
and as the default. It should help encourage people to use sudo aswell.
-Paul
--
Is there no safe way to travel? Nottingham, GB
More information about the ubuntu-users
mailing list