From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32581 invoked from network); 18 Jun 2021 16:35:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Jun 2021 16:35:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1624034139; b=nBSfXm5UhR2nkA0NKnpPMFGZVgoi9FAWibnU8Hn/cyHA94PAQdffOPVODWgNdXB0W4dKFkcDpt Sg5gY4sYtKIjBqq9ACzh5tlXdTFKrbTuccaINNbzCMk3bY95jzG000Fyt64Vpt8gUcx3L9GgJ4 gKcdDGhyYS99qbchZGghZ4F0TNF5MTJGBwvZGD8QA3/PucDUaiy7gqzzardqfoipz7rSt3KB8j Yz0bry4hA6AVZnELd2TLveFzbfcSbXkp5ef8up7HlQz1SurENr/FmMRLxdfNTwVKE8iMWAKPpw gR5IPTFrEsZNc9lbb93Ma4Vdrv2aVM85GYaQ/fqNvkmPeQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-il1-f172.google.com) smtp.remote-ip=209.85.166.172; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1624034139; bh=eqFj2s8f01aa5wkzAX24kvZy267QDAT/BtmfQy6TRgo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=hcBRkzrpwmgDlz5v1tDtecs1ciRiZroyRQj9syf/fjiMTQyymkXrKigVUh+D9tahLmFP2IqCfJ iLk+Dn1MYbm32K2SuH8/3/EE5NutUWsgGRo0UYiWnpCut8fvBIVGxAC8QCHlbh9RvZYuLRevt8 C2bcWXap5cv5qLHlWyY8ZaaZaHsIok9pg3e9XX2399rVfHd9SRm4cBtE4xZOgO+fvoTcVJxKgQ dw1pFolQNeHumbX1bXsJ+ZmERNXF9sh4JkzIOdcQEYMZmXMBtT0yNRC2SoROOoNssWglO/6W5u N93lu3xNqJ+ZnsVc+mijPZFCtZPrTWmjPaLm6t/vP6T8SQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=bKLpqT85M7tVs2jAo20VRmPm0TRFtaciT17IE/0PS8U=; b=oetNio9SXdP0+R+h7QQZn8Ys9K 8xmkQ6fwiZwBfBKWYc1BRz/7YuAekCyXFS2noNpztzIAmaWTqKExcLxQOBMwIB7tUyvJqdVyPJHjk BZmYxDAn/H/wLgLh7QplE7Lp/NK5szTV5enxd4UZaxa4hK8F3NXyAY3kE25BKpYgUGHyyLKE3d6Fy AmMH2OaOF6GohPtzV+zLHS7xjYb4wdY9K9c3meA4eYMDhFNmoP1DFDgIKOH0ME6H3/XEZ4etSbHOn fny2XyOPmAwd2t72u8auGghW5kYoN7ef9o+H/qSqUG7Kt6xDMnMH3wYUlFv/x8PMBn4zCTtIJJXTx J5tIaw8Q==; Received: from authenticated user by zero.zsh.org with local id 1luHSz-000M6Y-1z; Fri, 18 Jun 2021 16:35:37 +0000 Authentication-Results: zsh.org; iprev=pass (mail-il1-f172.google.com) smtp.remote-ip=209.85.166.172; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-il1-f172.google.com ([209.85.166.172]:34710) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1luHSO-000Lnn-Kx; Fri, 18 Jun 2021 16:35:01 +0000 Received: by mail-il1-f172.google.com with SMTP id s19so2194883ilj.1 for ; Fri, 18 Jun 2021 09:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bKLpqT85M7tVs2jAo20VRmPm0TRFtaciT17IE/0PS8U=; b=DPz6H/pCccwL0IZ1i34Bb0XT8EGVT9Z6O/md4C2/XCqxQPJcSPlg3aCT5DTkgn+unJ xxd8G6l5d8TbmEAytGs+oD/TrRYAs68TAQgdCEzzWQBTNS7cuqQYzB6E/J2jxEk2Fubw dDjg/GcKHrDKgz7UMjABm3Ttv4UkhhOj2yKBQ18qqlFlcoaDXpLqKQsY59e3psxIMxUh GVeQlvJkNz9u8XLexfyEvMY8LLu+OEZREJnIZ15TVP8VY632pDgudd/vrXfrmW9FD71J zUmpE6TgWF55rKBDpjMD0zJ2L76PZ3DJIUWfjBiGUTQSjQ/a0gcFbQuDvPLck0k2h+kn rfsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bKLpqT85M7tVs2jAo20VRmPm0TRFtaciT17IE/0PS8U=; b=HTXkN/7loEthsN+LyFYaBpQ2wZfs9ccMO0mG25go8jeg2ojGp103LEBAUgfaLD9SVQ PF+GkCBfh6hAdtX4e/cUefE1sjxAOLvLltj043NtuooIpXLegZDw7So/Tr9n+45nx8GQ CimWuMrVsaV5obBOEYYVdU88KjpivSPZDj1C0kLOUTghhyVwPDVFrgxCaES713N1Bd2/ dgESzeecXN6LpAIymNkQWcM6zOg9JdH2gbIKXNn1B1vSEHiamd2M9lNKay8z3q717lw8 ZIXzh9KaBBCaYTpNy9uyAArCXaaC/TBkIVq9Mji6dHnjstWuOOOefWVjM0ryYisdhXmA nUKQ== X-Gm-Message-State: AOAM531H3y8RKeoTA65Zm+xMPabYSltp6o61qX0ligHKCZHVbpl6IoIz fEmOQdfxbDdQ6UGifs/Um3CSESC83wTPJLNUWwo= X-Google-Smtp-Source: ABdhPJzu0dSNZB8DpE9pSSRRgdFxCY6+nH5GWL0+6VFrrSjrsfp2kzCMKKDGqGN4vyvHc20LCy2J5JtxERc1OEFCVsY= X-Received: by 2002:a05:6e02:1313:: with SMTP id g19mr3124900ilr.169.1624034098581; Fri, 18 Jun 2021 09:34:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Fri, 18 Jun 2021 18:34:47 +0200 Message-ID: Subject: Re: Wrapping special widget causes infinite recursion in add-zle-hook-widget To: Marlon Richert Cc: Zsh hackers list , Daniel Shahaf Content-Type: text/plain; charset="UTF-8" X-Seq: 49085 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Fri, Jun 18, 2021 at 3:32 PM Marlon Richert wrote: > > 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. I've bumped into similar issues with add-zle-hook-widget: https://github.com/romkatv/powerlevel10k/issues/1205#issuecomment-767496102 The first test case: autoload -Uz add-zsh-hook-widget add-zle-hook-widget # Add `foo` hook to zle-line-finish. function foo() {} add-zle-hook-widget line-finish foo # Invoke `bar` on zle-line-finish, which in turn invokes the original widget. zle -A zle-line-finish orig-zle-line-finish function bar() zle orig-zle-line-finish zle -N zle-line-finish bar # Add `baz` hook to zle-line-finish. function baz() {} add-zle-hook-widget line-finish baz This produces `bar: job table full or recursion limit exceeded` on zle-line-finish. Here's a similar test case but with a different effect. autoload -Uz add-zsh-hook-widget add-zle-hook-widget # Add `foo` hook to zle-line-finish. function foo() print -rl '' foo add-zle-hook-widget line-finish foo # Invoke `bar` on zle-line-finish, which in turn invokes the original widget. zle -A zle-line-finish orig-zle-line-finish function bar() { zle orig-zle-line-finish; print bar; } zle -N zle-line-finish bar # Add `foo` hook to zle-line-finish for the second time. add-zle-hook-widget line-finish foo This results in `foo` being called on zle-line-finish but `bar` doesn't get called. These look like bugs in add-zle-hook-widget to me. Both can be fixed. There is some choice w.r.t. the desired behavior of these test cases. I think it would be reasonable for the first to invoke `bar`, `foo`, `baz` (in this order) and for the second to invoke `bar`, `foo` (in this order). Here's one more test case to complete the picture: autoload -Uz add-zsh-hook-widget add-zle-hook-widget # Add `foo` hook to zle-line-finish. function foo() print -rl '' foo add-zle-hook-widget line-finish foo # Invoke `bar` on zle-line-finish, which does nothing. function bar() {} zle -N zle-line-finish bar # Add `foo` hook to zle-line-finish for the second time. add-zle-hook-widget line-finish foo I think it reasonable to require that `bar` and `foo` get called here (in this order). It's not too difficult to implement add-zle-hook-widget in a way that it conforms to these requirements and doesn't break the existing code that checks for `[[ $widgets[zle-line-finish] == user:azhw:zle-line-finish ]]`. Roman.