<div dir="ltr"><div><div>Hi, I found a bug in zsh completion and I posted it in oh-my-zsh [1]. Then I saw your repository and that you prefer pull requests via mailing list, so I did a format-patch which I post here. </div>
<div>This is the first time I do this, forgive me if I didn't paste the proper output; I'm pasting all of it just in case.</div><div><br></div><div>Cheers,</div><div><br></div><div>Marc Cornellà</div></div><div>[1] <a href="https://github.com/robbyrussell/oh-my-zsh/pull/2941">https://github.com/robbyrussell/oh-my-zsh/pull/2941</a><br>
</div><div>----------------------------------------------------------------------------------</div><div>From e250a37fefa4c0bdd3f6591b82b8cc455342826e Mon Sep 17 00:00:00 2001</div><div>From: =?UTF-8?q?Marc=20Cornell=C3=A0?= <<a href="mailto:marc.cornella@live.com">marc.cornella@live.com</a>></div>
<div>Date: Sun, 20 Jul 2014 18:22:04 +0200</div><div>Subject: [PATCH] Fix pass completion syntax and autoloading</div><div><br></div><div>When TAB is pressed, sometimes the following error appears:</div><div><br></div><div>
_values:compvalues:10: not enough arguments</div><div><br></div><div>From robbyrussell/oh-my-zsh#2846:</div><div><br></div><div>> It seems like this does not happen if I have passwords in pass.</div><div>> Only happens when pass is "empty".</div>
<div><br></div><div>This is due to lines 104 and 118, where there are the only `_values'</div><div>statements. If we follow the execution path it is also confirmed that</div><div>the responsible for that error is `_pass_complete_entries_helper()'.</div>
<div><br></div><div>The only thing left to try is the statement inside `$()', which returns</div><div>nothing. The output is blank, so `_values' only receives 1 of its 2</div><div>mandatory parameters.</div><div>
<br>
</div><div>To solve it, we wrap the `$()' argument inside double quotes. That way</div><div>even if the output of such command is blank, `_values' still receives</div><div>2 of its 2 mandatory parameters, therefore not complaining anymore.</div>
<div><br></div><div>This patch also fixes the first tab completion, which is dedicated to</div><div>loading the completion function instead of autoloading it properly.</div><div>We do this by adding a `_pass' statement at the end of the file, just</div>
<div>like any other completion file does and *needs* to do.</div><div>---</div><div> src/completion/pass.zsh-completion | 6 ++++--</div><div> 1 file changed, 4 insertions(+), 2 deletions(-)</div><div><br></div><div>diff --git a/src/completion/pass.zsh-completion b/src/completion/pass.zsh-completion</div>
<div>index b658398..f485042 100644</div><div>--- a/src/completion/pass.zsh-completion</div><div>+++ b/src/completion/pass.zsh-completion</div><div>@@ -114,7 +114,7 @@ _pass_cmd_show () {</div><div> _pass_complete_entries_helper () {</div>
<div> <span class="" style="white-space:pre"> </span>local IFS=$'\n'</div><div> <span class="" style="white-space:pre"> </span>local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"</div><div>-<span class="" style="white-space:pre"> </span>_values -C 'passwords' $(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' | sort)</div>
<div>+<span class="" style="white-space:pre"> </span>_values -C 'passwords' "$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' | sort)"</div>
<div> }</div><div> </div><div> _pass_complete_entries_with_subdirs () {</div><div>@@ -128,5 +128,7 @@ _pass_complete_entries () {</div><div> _pass_complete_keys () {</div><div> <span class="" style="white-space:pre"> </span>local IFS=$'\n'</div>
<div> <span class="" style="white-space:pre"> </span># Extract names and email addresses from gpg --list-keys</div><div>-<span class="" style="white-space:pre"> </span>_values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')</div>
<div>+<span class="" style="white-space:pre"> </span>_values 'gpg keys' "$(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')"</div><div> }</div><div>+</div><div>+_pass</div>
<div>-- </div><div>2.0.1</div><br></div>