New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #27504 (closed defect: fixed)

Opened 2 years ago

Last modified 11 months ago

bash completion and sudo password problem

Reported by: heapifyman@… Owned by: raimue@…
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: Cc: heapifyman@…
Port: bash-completion

Description

I installed macports, updated to 1.9.2, then installed the bash completion. When I press TAB key after entering

sudo port upgrade out

I get the following output in the Terminal:

sudo port upgrade outPassword:

and the command obviously doesn't work.

Change History

comment:1 Changed 2 years ago by macsforever2000@…

  • Cc heapifyman@… removed
  • Keywords bash completion sudo password removed
  • Port set to bash-completion
  • Owner changed from macports-tickets@… to raimue@…

Did you add this to your .bash_profile as instructed?

    if [ -f /opt/local/etc/bash_completion ]; then
        . /opt/local/etc/bash_completion
    fi

comment:2 Changed 2 years ago by heapifyman@…

Yes, I added above snippet to my .profile file as instructed, since I did not have a .bash_profile file.

comment:3 follow-up: ↓ 4 Changed 2 years ago by raimue@…

Hm, I can't reproduce this problem...

comment:4 in reply to: ↑ 3 ; follow-up: ↓ 6 Changed 2 years ago by heapifyman@…

Replying to raimue@…:

Hm, I can't reproduce this problem...

I should maybe add that I had

Defaults      timestamp_timeout=0

set in my sudoers file.

Without this, the problem does not occur

comment:5 Changed 2 years ago by heapifyman@…

  • Cc heapifyman@… added

Cc Me!

comment:6 in reply to: ↑ 4 Changed 2 years ago by heapifyman@…

Replying to heapifyman@…:

Replying to raimue@…:

Hm, I can't reproduce this problem...

I should maybe add that I had

Defaults      timestamp_timeout=0

set in my sudoers file.

Without this, the problem does not occur

Ignore the above, please. This only works if the password has been entered before, obviously. But for me, if the password has not been cached before, bash completion does not work if port command takes more than one argument, e.g.: pressing Tab after

port list a

produces

port list aPassword:

while something like

port installed

works as expected.

comment:7 follow-up: ↓ 9 Changed 2 years ago by raimue@…

Which version of bash do you use? I am not able to reproduce this with either /opt/local/bin/bash or /bin/bash. I do not see the password prompt, port names get completed as expected for me.

comment:8 Changed 2 years ago by raimue@…

  • Component changed from base to ports

comment:9 in reply to: ↑ 7 Changed 2 years ago by heapifyman@…

Replying to raimue@…:

Which version of bash do you use? I am not able to reproduce this with either /opt/local/bin/bash or /bin/bash. I do not see the password prompt, port names get completed as expected for me.

Bash version is:

/bin/bash --version
GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)

comment:10 follow-up: ↓ 11 Changed 22 months ago by heapifyman@…

The problem seems to be that I am working as a non-admin user and have to invoke the port command with prepening sudo. As I am a lazy person I thought I'd add an alias to my ~/.profile like this:

alias port="sudo port"

The problem described above only happens when this alias is active. Without the alias bash-completion works as expected. Is there some other way to avoid typing sudo all the time when using port command?

comment:11 in reply to: ↑ 10 Changed 13 months ago by ryandesign@…

Replying to heapifyman@…:

The problem seems to be that I am working as a non-admin user and have to invoke the port command with prepening sudo.

Even admin users have to do that. Only the root user wouldn't have to do that, but nobody would log into a Mac as root.

As I am a lazy person I thought I'd add an alias to my ~/.profile like this:

alias port="sudo port"

The problem described above only happens when this alias is active. Without the alias bash-completion works as expected.

Then I would say this isn't something we need to fix.

Is there some other way to avoid typing sudo all the time when using port command?

Nope; I typo sudo all the time too. Oh well.

comment:12 Changed 11 months ago by raimue@…

  • Status changed from new to closed
  • Resolution set to fixed

This was actually a problem in the way the completion was written, it should be fixed as of r95144.

comment:13 Changed 11 months ago by heapifyman@…

Thanks. It's working now after the latest update.

Only thing: I had to tell Terminal to use

/opt/local/bin/bash

instead of the default

/bin/bash

Maybe that could be added to the documentation somewhere?

comment:14 follow-up: ↓ 15 Changed 11 months ago by cal@…

It kind of already is in port notes bash-completion.

comment:15 in reply to: ↑ 14 Changed 11 months ago by heapifyman@…

Replying to cal@…:

It kind of already is in port notes bash-completion.

Sorry, I missed that during the install. I also added that note to the bash-completion how-to page: https://trac.macports.org/wiki/howto/bash-completion

Hope that is ok.

Note: See TracTickets for help on using tickets.