Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Wrapping special widget causes infinite recursion in add-zle-hook-widget



I originally reported this
[here](https://github.com/zsh-users/zsh-syntax-highlighting/issues/816)
but Daniel was of the opinion it should be fixed in
add-zle-hook-widget.

Steps to reproduce are as follows:

% foo bar () { }
% autoload -Uz add-zle-hook-widget
% add-zle-hook-widget line-init foo
% zle -N old-zle-line-init azhw:zle-line-init
% new-zle-line-init() { zle old-zle-line-init }
% zle -N zle-line-init new-zle-line-init
% add-zle-hook-widget line-init bar
[Process completed]

The test case here uses zle-line-init, but it's not specific to that
widget. It can be reproduced with any of the special widgets that
add-zle-hook-widget handles.

See attachment for xtrace.
% foo bar () { }
% autoload -Uz add-zle-hook-widget
% add-zle-hook-widget line-init foo
% zle -N old-zle-line-init azhw:zle-line-init
% new-zle-line-init() { zle old-zle-line-init }
% zle -N zle-line-init new-zle-line-init
% functions -T add-zle-hook-widget
% add-zle-hook-widget line-init bar; functions -T azhw:zle-line-init
+add-zle-hook-widget:1> local -a hooktypes
+add-zle-hook-widget:2> zstyle -a zle-hook types hooktypes
+add-zle-hook-widget:5> local usage='Usage: add-zle-hook-widget hook widgetname\nValid hooks are:\n  isearch-exit isearch-update line-pre-redraw line-init line-finish history-line-set keymap-select'
+add-zle-hook-widget:7> local opt
+add-zle-hook-widget:8> local -a autoopts
+add-zle-hook-widget:9> integer del list help
+add-zle-hook-widget:11> getopts dDhLUzk opt
+add-zle-hook-widget:38> shift 0
+add-zle-hook-widget:40> 1=line-init 
+add-zle-hook-widget:42> ((  list  ))
+add-zle-hook-widget:45> ((  help || 2 != 2 || 4 == 0  ))
+add-zle-hook-widget:50> local -aU extant_hooks
+add-zle-hook-widget:51> local hook=zle-line-init
+add-zle-hook-widget:52> local fn=bar
+add-zle-hook-widget:54> ((  del  ))
+add-zle-hook-widget:71> [[ bar = zle-line-init ]]
+add-zle-hook-widget:81> integer i=3-2
+add-zle-hook-widget:82> zstyle -g extant_hooks zle-line-init widgets
+add-zle-hook-widget:84> [[ user:new-zle-line-init != user:azhw:zle-line-init ]]
+add-zle-hook-widget:85> [[ -n user:new-zle-line-init ]]
+add-zle-hook-widget:86> zle -A zle-line-init user:new-zle-line-init
+add-zle-hook-widget:87> extant_hooks=( 0:user:new-zle-line-init 1:foo ) 
+add-zle-hook-widget:89> zle -N zle-line-init azhw:zle-line-init
+add-zle-hook-widget:92> [[ -z '' ]]
+add-zle-hook-widget:95> i=1+1 
+add-zle-hook-widget:99> extant_hooks+=( 2:bar ) 
+add-zle-hook-widget:100> zstyle -- zle-line-init widgets 0:user:new-zle-line-init 1:foo 2:bar
+add-zle-hook-widget:101> ((  ! 0  ))
+add-zle-hook-widget:102> autoload -- bar
+add-zle-hook-widget:103> zle -N -- bar
+add-zle-hook-widget:105> ((  ! 1  ))
% +azhw:zle-line-init:1> local -a hook_widgets
+azhw:zle-line-init:2> local hook
+azhw:zle-line-init:5> zstyle -a zle-line-init widgets hook_widgets
+azhw:zle-line-init:6> hook=user:new-zle-line-init
+azhw:zle-line-init:7> [[ user:new-zle-line-init = user:* ]]
+azhw:zle-line-init:9> zle user:new-zle-line-init -N --
+azhw:zle-line-init:1> local -a hook_widgets
+azhw:zle-line-init:2> local hook
+azhw:zle-line-init:5> zstyle -a zle-line-init widgets hook_widgets
+azhw:zle-line-init:6> hook=user:new-zle-line-init
+azhw:zle-line-init:7> [[ user:new-zle-line-init = user:* ]]
+azhw:zle-line-init:9> zle user:new-zle-line-init -N --
+azhw:zle-line-init:1> local -a hook_widgets
+azhw:zle-line-init:2> local hook
+azhw:zle-line-init:1> local -a hook_widgets
+azhw:zle-line-init:2> local hook
+azhw:zle-line-init:5> zstyle -a zle-line-init widgets hook_widgets
+azhw:zle-line-init:6> hook=user:new-zle-line-init
+azhw:zle-line-init:7> [[ user:new-zle-line-init = user:* ]]
+azhw:zle-line-init:9> zle user:new-zle-line-init -N --
+azhw:zle-line-init:1> local -a hook_widgets
+azhw:zle-line-init:2> local hook
[repeats until zsh crashes]


Messages sorted by: Reverse Date, Date, Thread, Author