Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete choices for a2enmod / a2dismod etc. #2141

Closed
n3o77 opened this issue Jun 20, 2015 · 13 comments
Closed

complete choices for a2enmod / a2dismod etc. #2141

n3o77 opened this issue Jun 20, 2015 · 13 comments
Assignees
Labels
Milestone

Comments

@n3o77
Copy link

@n3o77 n3o77 commented Jun 20, 2015

i'm having trouble to get auto completion running for a2enmod, a2dismod, a2ensite and so on. with bash i can just type "a2enmod " and get a list of all available mods. is there a way to do this with fish as well? another problem i'm having is that i don't get proper suggestions for sudo. when i'm typing as my user "sudo a2e" I don't get any suggestions, but executing "sudo a2enmod" works just fine.

thank you very much in advance!

@zanchey
Copy link
Member

@zanchey zanchey commented Jun 26, 2015

The first problem is easy enough to fix - completions for a2{en,dis}{mod,site} are pretty easy to write.

The second example works fine for me on 2.1.1 and 2.2b1 - what version are you running?

zanchey added a commit that referenced this issue Jun 26, 2015
@zanchey zanchey added this to the next-2.x milestone Jun 26, 2015
@n3o77
Copy link
Author

@n3o77 n3o77 commented Jun 26, 2015

Thank you very much!
I'm running version 2.1.1 on debian wheezy.

@faho
Copy link
Member

@faho faho commented Jul 16, 2015

The completions are now written, so the question remains:

Is the sudo thing still occuring? Does it also happen with fish 2.2.0?

@n3o77
Copy link
Author

@n3o77 n3o77 commented Jul 16, 2015

Yes, I'm still having the problem with sudo in 2.2.0. Completions aren't in 2.2.0, right?

@faho
Copy link
Member

@faho faho commented Jul 16, 2015

No, they aren't - though you can download them manually and add them to ~/.config/fish/completions/.

Do you have any sudo function/alias (type sudo)? Otherwise __fish_complete_subcommand_root is not working as it should.

@n3o77
Copy link
Author

@n3o77 n3o77 commented Jul 16, 2015

OK i just took another look and it seems that it's partially Working. See screenshots.

/v/www  type sudo
sudo is /usr/bin/sudo

As user:
screen shot 2015-07-16 at 20 20 19

As root:
screen shot 2015-07-16 at 20 24 52

@faho
Copy link
Member

@faho faho commented Jul 16, 2015

I have an idea:

 getfacl (which a2enmod)

It appears that fish will not complete commands you can't execute (though I'll be damned if I find where that's defined).

@n3o77
Copy link
Author

@n3o77 n3o77 commented Jul 16, 2015

root@my ~# getfacl (which a2enmod)
getfacl: Removing leading '/' from absolute path names
# file: usr/sbin/a2enmod
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
@zanchey
Copy link
Member

@zanchey zanchey commented Jul 17, 2015

I think the problem here is that because PATH is set as a local variable in the __fish_complete_subcommand_root scope, it is not reflected in the __fish_complete_subcommand scope.

Certainly adding --no-scope-shadowing to the definition of __fish_complete_subcommand seems to fix things.

I'm wondering if this got broken by the change to top-level scoping or something, although I doubt it.

@zanchey
Copy link
Member

@zanchey zanchey commented Jul 17, 2015

This worked in 1.23.1 (!) but I think b0c6d89 broke it well before 2.0.0. I don't think the change is wrong; certainly it doesn't seem wise to alter the global PATH, but I'm not 100% sure that --no-scope-shadowing is sensible in __fish_complete_subcommand; thoughts welcome!

@faho
Copy link
Member

@faho faho commented Aug 5, 2015

Either adding an option to __fish_complete_subcommand or duplicating it in __fish_complete_subcommand_root should work.

@faho
Copy link
Member

@faho faho commented Sep 28, 2015

I'm not 100% sure that --no-scope-shadowing is sensible in __fish_complete_subcommand; thoughts welcome!

@zanchey: As far as I understand, "--no-scope-shadowing" means that the calling "local" scope is inherited, right? __fish_complete_subcommand defines all variables it uses as local and __fish_complete_subcommand_root doesn't use any variables of the same name after the call (in fact it does nothing).

So I don't see any bugs popping up because of that change - though it'd mean we'd have to be careful. But given that the last change to __fish_complete_subcommand was in 2012, I think it's rather stable.

The other options I see are:

  • Duplicate __fish_complete_subcommand's logic in __f_c_s_r (as in "literally copy all the code in")
  • Add an option to __f_c_s to take a path
@zanchey zanchey self-assigned this Oct 21, 2015
@zanchey
Copy link
Member

@zanchey zanchey commented Oct 21, 2015

I went with the easy option in f68b339 - this should work now.

@zanchey zanchey closed this in f21d826 Oct 21, 2015
@faho faho added the release notes label Oct 26, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.