View previous topic :: View next topic |
Author |
Message |
runem n00b
Joined: 08 Sep 2006 Posts: 40
|
Posted: Fri Aug 19, 2011 8:18 pm Post subject: (Solved) Bash-completion does not work for sudo |
|
|
Hi
Normal completion of bash-commands and filenames seems to work but combined with sudo it does not. If I have a file in the current directory which matches a command then the filename will be used. Example: I have a file 'emerge-log.txt' and when I want to run 'sudo emerge ....' the result is 'sudo emerge-log.txt'. What module must be activated? I have an other machine where it works, but I cannot find the difference.
Last edited by runem on Mon Aug 22, 2011 3:23 pm; edited 1 time in total |
|
Back to top |
|
|
dwbowyer Apprentice
Joined: 18 Apr 2008 Posts: 155
|
Posted: Fri Aug 19, 2011 8:44 pm Post subject: |
|
|
Code: |
eselect bashomp list
|
Doesn't show me a sudo module, which to me makes sense. Until sudo runs, how would bashcomp know which commands you would have access to...
What I mean is, a normal or restricted user doesn't have access to all commands, or necessarily even permission to view directories that contain commands. So bashcomp wouldn't list those anyway, with sudo in the mix it would have to run and access the sudoers list before bashcomp could do it's thing. Therefore, rightfully:
would only expand to files in the current directory. |
|
Back to top |
|
|
runem n00b
Joined: 08 Sep 2006 Posts: 40
|
Posted: Fri Aug 19, 2011 9:09 pm Post subject: |
|
|
The user is in the portage group so 'emerge -p stuff' works with completion of the command. It should work with sudo too. It works on one machine and not the other so it must be some kind of missing setup. |
|
Back to top |
|
|
b0nafide Apprentice
Joined: 17 Feb 2008 Posts: 171 Location: ~/
|
Posted: Sat Aug 20, 2011 4:38 am Post subject: |
|
|
su
yoursecretpassword
auto-complete to your hearts desire
exit?
Just because sudo is mostly used for running as root doesn't mean that it can't be used to run as other users. If sudo were to concatenate all of the possible users PATHs just for the convenience of auto-completion by any user capable of executing sudo, I wouldn't like it at all.
edit: I must not have been taking my meds when I wrote this.
Last edited by b0nafide on Tue Aug 23, 2011 5:17 pm; edited 1 time in total |
|
Back to top |
|
|
l4nce n00b
Joined: 27 Feb 2011 Posts: 15
|
Posted: Sat Aug 20, 2011 5:00 pm Post subject: |
|
|
To use auto completion with sudo You must add to your .bashrc
I have same thing set to man
I think it is what You mean. |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Sun Aug 21, 2011 2:00 pm Post subject: |
|
|
For sudo you need to enable the base eselect bashcomp module:
Code: | eselect bashcomp enable base |
_________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
albright Advocate
Joined: 16 Nov 2003 Posts: 2588 Location: Near Toronto
|
Posted: Sun Aug 21, 2011 2:47 pm Post subject: |
|
|
Quote: | complete -cf sudo
complete -cf man |
that's nice .... thanks _________________ .... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme) |
|
Back to top |
|
|
runem n00b
Joined: 08 Sep 2006 Posts: 40
|
Posted: Mon Aug 22, 2011 3:25 pm Post subject: |
|
|
tomk wrote: | For sudo you need to enable the base eselect bashcomp module:
Code: | eselect bashcomp enable base |
|
That worked. Thanks! |
|
Back to top |
|
|
|