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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28373 invoked from network); 25 Jun 2021 17:35:04 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Jun 2021 17:35:04 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1624642504; b=JyktLV2AEMulTkDuU4DDYpd1xxUVIuHpfqZVR/UJkg7UWY7tlnd+2aODEEsiYkMRTBEyHDPiHM wpJLYcKJztBwepxJzjNxGFrCjbxPL/SPmY2pBesVRKeZ018QodfzwTkrGPaw+sF/bxyW0k+FGX 6IZa4YFUWJ6D+9EYF4rG+PrZDsc8wMQuVN6BXrzIwkcR6daPOBynbeSnZT11NoGZLKOgocd8TT B0PEI0buc8EgpFDfouztCieyF/q8qM1C/Q05Wx7Jii+7TIyw9V7MKN6HpZzJaQFVnrrWJNv5iS idiFXojqpaPjngl5KvtUWbssNu31t3zybpnJIM677PwbOw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1624642504; bh=2z3KkYzP9R+4m2hBOlwCZmyRXG2IvGrmMjK9XP0HwvQ=; 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=HOI+hpwx3ryZiuSvpaw+ZdJkS5ewLim5kduIn9QKV3HS7qaycWQwzwAxYfc1wVI8W2WgrS2+yE l0Wlgp3+uKEcnEdsdx/FcH371bSK6zoLgjuOyKkn48DrHE31ZoYIdvQfcs/FtfogDNS5LDrSj2 QQYZjDajXsQuSDvQ5NqNu167iNkEfLqA9YhQdjxXyMWFxBzshd/QsFljDyBHoebwNgwd0Wx973 25CFCYsbJRZL0lqId0/JI+xB0OqJzZ+XsokdHhq0gbaXF7qQQPB/EG7/6WvKYFiamvlSwOO48b FAdbc6YoTtAbFORslrH7Sxw2EIRHWsDB3gx6ByyEbfa9YQ==; 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=YpGu0lekVeghwlkheVMVe6WPGzZYx1omme7LEqUyY44=; b=OJfghctay830fnFdwUUaDhZdA7 yKOMRBG2OjM0H6JhfifJj9oEEM037RIZJNYyD+ATAKJaXkud77iw2pCLdAt9tTPS77+vV7SkpwnRm P9yEqqgolZg8AbqwaiNGgIijMoy2jfChUIUcoSFaGE8VMgNwoNa7WaF5cHQntIMhB1VMcnV1e5O6f kGPegCvAxcjGcoUyi2c0i67mjMJP9gcvv+RYjfIHfex0vvGfvgh3l9fgzgkj/MmcGcM3UwdNQTQ9r hEOsn5ptZQnZQi52KKEXSFjPxdgtmf0PzRbGP99fpawvME0S7NXZjiLg1IZyXhIN/U/grzuo0+Use VQiPhmsw==; Received: from authenticated user by zero.zsh.org with local id 1lwpjI-000Aiv-Pz; Fri, 25 Jun 2021 17:35:00 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ot1-f50.google.com ([209.85.210.50]:46061) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lwpie-000APo-Ux; Fri, 25 Jun 2021 17:34:22 +0000 Received: by mail-ot1-f50.google.com with SMTP id 6-20020a9d07860000b02903e83bf8f8fcso10011258oto.12 for ; Fri, 25 Jun 2021 10:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YpGu0lekVeghwlkheVMVe6WPGzZYx1omme7LEqUyY44=; b=VkBzVHjXsyoH+DRByOIEoxgebS7vdCfStkiJz5yhyukjdo7gxmcunxZqWE82aPX2MM 4xGdbluSV1U/sEd4JBSJV8lZ1l6o/E8l+Po5NFSkK7GXCGxWQEMRRaXYZFM8ZWPoaRwL +WKuwqK2pH0wq33MXQds0ijC2OIEQcsWS/TXvCcPW/L/tWNWq82o6btahnFbkJdmw7EJ Ax2vrEboh6c12V7YoEmzly1vGMNejzS+qVyQNYAU+1lQJXa01gylbXKWukSFbPSKDpRi xVnww8NDzxf4AD9fndbT4hMbTp4wRy6eKPgx9HBbQJshWgRr/KIRcpzqRhxo48w15lP5 /cbw== 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=YpGu0lekVeghwlkheVMVe6WPGzZYx1omme7LEqUyY44=; b=DeRhJmm+F9DZqw6NKaaHPdWQDu2oObVMMbp4tMJ2iJoEuK6U1ONHRDKadKd8RprGEP Jzr+Qw+f8zuiG+g2MlRjWVPttTZBMcXGfTH3H31PiABvPUJdwgmZxiOg1owOTy7ZQwdc Ocu8DDsRMwFMO13neGIExX5EPxg4nsVn26WwLuMp7QN9Azg8uXkrY8DYoQzCtGWIdDAU kw+5SLLa1aj+C/ENkVQHgSTU2Gk0seWC4wydsCO3C/OxLmmRWBxEwyP8EFz7QpxDS3E3 m4qixWseqHV/7ys70aqAau9czhKqluExYD1dKuozh3VnKvFFzqytXsdA6Bh5KRe9rogw jJyw== X-Gm-Message-State: AOAM530VsDcPESKARNFmVgmBdNhU4AkyLQ9hgCBntbpuRW6TpQAnOgdF Nke8WXaiWGe9n+hoq6N0X0qUwxyyUa5/dUBxdofD2A== X-Google-Smtp-Source: ABdhPJz3EnLGzzv21IcOFuSjuOC8nKWlTwhioZj+3qxeVbnOcMRMRmy1uBp5nNQxK+C54acirWtNUC56JZaCdcGyLEc= X-Received: by 2002:a9d:4c9a:: with SMTP id m26mr10773605otf.229.1624642459503; Fri, 25 Jun 2021 10:34:19 -0700 (PDT) MIME-Version: 1.0 References: <9c56f50a-d061-4175-958a-6f89f6bae822@www.fastmail.com> <20210624183006.GA16386@tarpaulin.shahaf.local2> In-Reply-To: From: Bart Schaefer Date: Fri, 25 Jun 2021 10:34:08 -0700 Message-ID: Subject: Re: Does add-zle-hook-widget violate the contract of ZLE hook widgets? To: Marlon Richert Cc: Daniel Shahaf , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49124 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 Thu, Jun 24, 2021 at 2:49 PM Marlon Richert wrote: > > That makes sense, but then, it should also be documented what that > actually means. If your function returns zero/non-zero, what is > expected to happen? Does this always happen? Or are there different > classes of functions with different results for zero/non-zero? The convention is that returning zero means success (the canonical example being the "true" command) and nonzero means some kind of failure ("false"). The actual numeric value of the non-zero return might mean something. Theoretically every command (function, builtin, script, whatever) that "succeeds" should be returning zero; the fact that this is sometimes ignored (and that for example the return/exit status of the last command executed within the function body is retained as $? instead) is programmer laziness. > I can already think of two examples that contradict each other: > * In hook functions, callee returning NON-zero causes the caller to > refrain from calling more functions. > * In completion functions, callee returning ZERO causes the caller to > refrain from calling more functions. These are not really contradictory; you're ignoring important context. In both cases zero means success and nonzero means failure. The context determines what that signifies. For completion functions, success means that completions have been generated and further work is not necessary, failure means it's reasonable to try a different approach. For hook functions, success means that it's OK to proceed, and failure means that something bad happened and further work is potentially dangerous. You can't just look at the return codes in isolation and say "these are reversed" without considering what success or failure means in context. In either case we could actually extend the model to use different nonzero values of $? to distinguish "try something else" and "danger, abort" conditions; it just happens that for hooks, currently anything nonzero is considered "danger, abort" and for completion it is always "try something else".