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

Update pass completion and fix syntax and autoloading #2941

Merged
merged 3 commits into from Aug 31, 2014

Conversation

mcornella
Copy link
Member

STATUS: TESTED, WAITING FOR INPUT.

Fixes #2846, closes #1480.
/cc @sanbor @christianschmidt


This pull request fixes the copyright notice (by @sanbor) and updates the zsh pass completion to the current one on the upstream project.

It also fixes the errors that appear in #2846 and the first TAB completion.
Refer to mcornella@4bf87c2 for more information.

@mcornella mcornella changed the title Fix pass completion syntax and autoloading. Fixes #2846 Fix pass completion syntax and autoloading Jul 20, 2014
@mcornella mcornella changed the title Fix pass completion syntax and autoloading Update pass completion and fix syntax and autoloading Jul 20, 2014
@mcornella
Copy link
Member Author

I submitted a PR to the mailing list of the password-store project. Expect a response in the following week

@sanbor
Copy link
Contributor

sanbor commented Jul 27, 2014

I was able to reproduce the bug #2846 and with @mcornella's PR the issue it's fixed. Thanks for the patch and sorry for the delay to reply.

Santiago Borrazás and others added 3 commits August 29, 2014 00:39
Conflicts:
	plugins/pass/_pass
When autocompleting from `pass <TAB>', sometimes the following errors
appear:

  _values:compvalues:10: not enough arguments
  find: `/home/user/.password-store': No such file or directory
  _values:compvalues:10: not enough arguments
  find: `/home/user/.password-store': No such file or directory

The `_values' error happens when there is no password-store folder *or*
there are no passwords in pass; the `find' error only when there is no
password-store folder.

We can trace it back to line 108, which contains the only `_values'
statement that is executed when we autocomplete from pass. We confirm
this by following the trail of execution, which is

  _pass -> _pass_cmd_show -> _pass_complete_entries ->
        -> _pass_complete_entries_helper

If we try running the command inside `$()' on line 104, we see that it
returns nothing and the output is blank. This means that `_values' only
receives 1 of its 2 mandatory parameters, therefore the above error is
triggered (not enough arguments).

That is unless we don't have a password-store folder, in which case the
`find: [...] no such file or directory' error is *also* triggered.

We solve the first error by supplying a default value of "" if the
command outputs nothing, using the zsh construct ${var:-else}.

We solve the second error by redirecting the find command's stderr output
to /dev/null, so the error is effectively suppressed.

* * * *

This patch also fixes the first tab completion, which currently only
loads the completion function definition.

We do this by adding a `_pass' statement at the end of the file, which
runs the `_pass' completion function after loading its definition.
This is the standard way an autoloaded function works; for other examples
look at zsh's official completion files.
robbyrussell added a commit that referenced this pull request Aug 31, 2014
Update pass completion and fix syntax and autoloading
@robbyrussell robbyrussell merged commit 6caed46 into ohmyzsh:master Aug 31, 2014
@AndrewKvalheim
Copy link

Thanks!

@mcornella mcornella deleted the fix-pass-completion branch August 31, 2014 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_values:compvalues:10: not enough arguments
4 participants