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 26554 invoked from network); 9 Aug 2021 21:28:09 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Aug 2021 21:28:09 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1628544489; b=Ak1qX5PapqImQlo2c0EL9pb+zzIP+c08sVJjW18IKJ6P3HGVutcQBFZs3yVo2T8bcn7w3mHA3Y 3oA2/K7UPkU52a88WqTC3CNung9/N2dXp8etepwB5lEzy667F0pCcjUoe5cFSQUcNR+PJu3VGK aTrF1EWji5GpwHwMLG5IYE6fyCUMFwwSwSoQmNxu7vBuif6hkf6g08PjQ/3zvOqMMWkcs3EPyq 9WeXU5ydjbeQMIpjlwhK1BEjmGnG3rBW7gv5f8sW7CCCXaVD4V95gxuTKBSQOzqjx253fN7qgi sR1qOHhdHx0sHg5Fz028fpwYfJSwZ/ffQ4C1f3hHc7F8mQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f182.google.com) smtp.remote-ip=209.85.219.182; 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-20210803; t=1628544489; bh=qXXbOl1389amd+RK8t14lWI/HNwDxVp1sNe+1KnQKcM=; 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=o2sNj2Ke3WHs0SryhWv2fzpwaWkw7Usa3mgg/L8RfvvhIW3z2IX2SYGUJd1gbS3FfCU6pKAH3E jq/SFTuWxxrOQ/bufMvrl+ICEQso44Qg5dH2a1pNbrAf0k21uZjYLuwUGNYZ0olw599+eTsgL1 3Ogo2nk7LJ7MmjXWMxOxZGFptK6IeC013tktW6pguwM0KbMtGOTwE0vRRk9ucwrJ6itGe5f0K7 ym8TQK8oEHhwzZ3zBKF/qadd7FC1JVEZD18IywF+HCTzsCIbctAZLZqTX2ajnSmwhQJrWNgqa/ 19BGBC0UmnDxC0WMqlB+A1FTVQk5jo89gZfyp8Vh/yUUNg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; 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=jMW1C5VF9sBlhbC132Ug13Otat+EQwKHeJAg/ig1ywY=; b=Pw3k+W3YM/jC5Rc5DRjXJiWoHX 03T0knoh9e8pCF+i3OzosuivGH71HNcVCLizxrZVY8ZfDQfjcbHAYWam4wefwND2w7WZ4tSEvUlKQ YzrfyIzHugyzKhID/Niwz2zqUZpoFGXkwnwH1R2mciT0Jj3qrUXshKCPfq3OcEMKzGde8lU8EpoZM OJkueyv+cs5HmSUFSMVlzkx1h3B3474paoc+KRpMc+zymAwpi+fCzgxHmz5ckVFCyGkSpVTf1OYK/ 2VtRXzYoJGSzQC/94qCJmk1lfas+qxrXIHGXsQCs3XrL1d7nzzgQKwW7RGdKTtPNjTjVhk31LLuHC QVzbLHjw==; Received: from authenticated user by zero.zsh.org with local id 1mDCoa-000LXa-NM; Mon, 09 Aug 2021 21:28:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f182.google.com) smtp.remote-ip=209.85.219.182; 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-yb1-f182.google.com ([209.85.219.182]:33501) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mDCne-000KpR-QT; Mon, 09 Aug 2021 21:27:11 +0000 Received: by mail-yb1-f182.google.com with SMTP id x192so32290665ybe.0 for ; Mon, 09 Aug 2021 14:27:10 -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=jMW1C5VF9sBlhbC132Ug13Otat+EQwKHeJAg/ig1ywY=; b=HX4xkXgUMYztRSOa30/xwM3YXMFWroBo5Ftz2xhBQDwbXnTuP2oeLR2eLC+ZZV5AVF dVNwZJk+VVvXqg/4pM3tvyyDWxfgOn/ddbvAj/3eE+mqX2VC5WYgNwcV9/Sw/L80xr+H Vcb1HD6Ul+hqEJST30SZ3D7fbxRLrS6eBjAUdstRbXGxz9NqCAlpsRfpuM1WqP0Z2NK4 bO4uRPEGLbimEXl9VYYuotYcIWYTnQXTZSeoHr+bqyKEyLfTc/RCY/ZoddDPQbIVDR4f GTiPYrWG7VeFWFSKnoKK6FlVV4zOhH+ZYM51gdoNqGI7N/358ydgWdWUcyMWnxz062nl eEsQ== 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=jMW1C5VF9sBlhbC132Ug13Otat+EQwKHeJAg/ig1ywY=; b=CTOXJw6Of3GV3y4qGN9VrCQ4yh4DT0bW8HQHX7cUU8k/Kny+Z4jLcKi2FOD86iqkfP rj3N1ByC4KRU+dvcM8ZB4oenVjfikj7Sma4ZSYcA/1IUt6pDgv2Tc+aLDjfqf1NYoekO ETFGqbmtz/GzjsUhJ0WVD5b2rwddphzgS1JOABgf66NYTVDarfqsSmqTr0/aABR8/txJ Xe+LtE5qGPmzJRAa+YUYj/65muH+K8h1s1DdHTI92fl5jqicSA/3LBqrjPxRLsefAdsv RexHix/3vrrfzolqJxXe6bEwZKYBDXQfVd512f/pM6wm+53HHYPKkujLnrlL1wn8z9Vp 0aaw== X-Gm-Message-State: AOAM5313uxw+UCj3zSrAaOHcL2M73YRnVdHdz/YyTIaU0iTdXw3/uRSm l+3ZnffTPI8ozK/KdzJ6Org/YLRcPjdRTwrdeTIri1ZAHE0= X-Google-Smtp-Source: ABdhPJzAKHQWeqB+3ubDmwBbGEd/xVcAXug5aIwRq68FFYgxXyAfLSMD+hnRUuRVytnMlTVpsy8wGx/cN+PgzTAHQJE= X-Received: by 2002:a25:31c5:: with SMTP id x188mr34633187ybx.291.1628544429579; Mon, 09 Aug 2021 14:27:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Mon, 9 Aug 2021 14:26:58 -0700 Message-ID: Subject: Re: chpwd, precmd hooks have "zsh" in $0 To: Roman Neuhauser Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 26884 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Mon, Aug 9, 2021 at 1:16 PM Roman Neuhauser wrote: > > as the subject says, at least the chpwd and precmd hooks > have the shell's argv[0] in $0. This is because (most) hook functions are called with an empty (NULL) argument list, as opposed to e.g. all commands (external, builtin, or function) run from a command line, which have a non-empty argument list starting with the command name itself. In the particular case of preexec, the argument list is empty any time history is not active, which is the case when loading a script with "source" or "." builtins. If you actually try it from the interactive command line, you'll see that $0 is "preexec" in the call to every function in the preexec_functions list. I'm not sure what the desired behavior is here. callhookfunc() could dummy up a LinkNode any time its lnklst argument is empty, and then all the hooks would behave in the manner preexec behaves when history is enabled; or doshfunc() could do the same, in which case every hook-array function would have its own name in $0; or neither of the above is appropriate and we should document the current behavior.