bound widget return code lost #135

Closed
stnutt opened this Issue Mar 12, 2016 · 5 comments

2 participants

@stnutt

For a bound widget, the return code of the invocation of the original widget is not returned.

This a problem with zaw where the zaw-select-src widget will return 1 in the event a send-break is issued or if there are no matches, telling zaw to exit.

@ericfreese
zsh-users member

You are right that the return code of the original widget is not being correctly returned, but I have yet to personally find a case where it's needed, and I'm having trouble reproducing the error you're describing.

I'm not familiar with zaw, and I honestly don't understand what the point of it is, but this is what I've tried:

% zsh -f
%% source ~/.zsh/zsh-autosuggestions.zsh
%% source ~/.zsh/zaw/zaw.zsh
%% bindkey '^R' zaw-select-src
%% bindkey '^G'
"^G" send-break
# I then press '^R' to invoke zaw-select-src.
# After the select source menu comes up, I press '^G' to issue a send-break.
# Zaw exits and I'm returned to the prompt. All seems fine.

Can you give a clearer description of what exact problem you're having?

@stnutt

Sure. WIth zaw sourced, you press CTRL-x followed by semicolon to start the zaw widget. Zaw itself then invokes the zaw-select-src widget, which is what draws and filters the menu. This widget will then exit if you press CTRL-g (send-break) or hit enter and return control back to the zaw widget. If you've hit CTRL-g or hit enter without matching anything then zaw-select-src will return 1 indicating to zaw that there's no match and there's nothing else to do. However, with the widget bound, zaw-select-src always returns 0, and zaw thinks that there's a match and that there's something to execute which results in the following error because it's trying to execute a command that's just an empty string.

zaw:20: permission denied:
now loading ...

You can see zaw calling zaw-select-src and checking the return code in zaw.zsh at around line 80.

I imagine that there's probably other use cases where having the return code is necessary.

@ericfreese
zsh-users member

Awesome, thanks for all the detailed info! I'll fix this soon.

@ericfreese
zsh-users member

@stnutt Just pushed a fix to branch fixes/bound_widget_return_code. Please try that branch and let me know if it solves the problem for you.

See PR #140.

@ericfreese
zsh-users member

Went ahead and merged. Should be fixed with the release of 0.3.2

@ericfreese ericfreese closed this Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment