Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
(Solved) Bash-completion does not work for sudo
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
runem
n00b
n00b


Joined: 08 Sep 2006
Posts: 40

PostPosted: Fri Aug 19, 2011 8:18 pm    Post subject: (Solved) Bash-completion does not work for sudo Reply with quote

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
View user's profile Send private message
dwbowyer
Apprentice
Apprentice


Joined: 18 Apr 2008
Posts: 155

PostPosted: Fri Aug 19, 2011 8:44 pm    Post subject: Reply with quote

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:

Code:

sudo emerge...
would only expand to files in the current directory.
Back to top
View user's profile Send private message
runem
n00b
n00b


Joined: 08 Sep 2006
Posts: 40

PostPosted: Fri Aug 19, 2011 9:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
b0nafide
Apprentice
Apprentice


Joined: 17 Feb 2008
Posts: 171
Location: ~/

PostPosted: Sat Aug 20, 2011 4:38 am    Post subject: Reply with quote

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
View user's profile Send private message
l4nce
n00b
n00b


Joined: 27 Feb 2011
Posts: 15

PostPosted: Sat Aug 20, 2011 5:00 pm    Post subject: Reply with quote

To use auto completion with sudo You must add to your .bashrc

Code:
complete -cf sudo


I have same thing set to man

Code:
complete -cf man


I think it is what You mean.
Back to top
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Sun Aug 21, 2011 2:00 pm    Post subject: Reply with quote

For sudo you need to enable the base eselect bashcomp module:

Code:
eselect bashcomp enable base

_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2588
Location: Near Toronto

PostPosted: Sun Aug 21, 2011 2:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
runem
n00b
n00b


Joined: 08 Sep 2006
Posts: 40

PostPosted: Mon Aug 22, 2011 3:25 pm    Post subject: Reply with quote

tomk wrote:
For sudo you need to enable the base eselect bashcomp module:

Code:
eselect bashcomp enable base


That worked. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum