Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ZSH_XTRACE_FILE (instead of ZSH_XTRACEFD)
- X-seq: zsh-workers 54226
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Charles Blake <charlechaud@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: ZSH_XTRACE_FILE (instead of ZSH_XTRACEFD)
- Date: Wed, 18 Mar 2026 15:44:30 +0100
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8eMgf4y2p83BfeYv5DQfGEjHoB18ZVgIIIreACvGQ5s=; fh=lNwkaVSUgCqMTMeZdgLy2I+b6F4zkEqzT0VbYWrffUU=; b=GXXFr1Y5sJdWHTbow1A5EUoxPqZhn51jyKE0fBoh01SsviZmi85WeA2aRTVkf4XRN+ DDA5l3mCe6rHf0i8Y9NMBNf0aYUfW+unpBM9EK3+qC2bf/Utpn0PDrcs8QJE6ETzhh/E zeLeKWy+Y8TBjAUl1VJMWuKlGw0PujPGTo2kj1LSMf7SjJ922UyeSMsUxAOm+QS6y093 mLZRfy/E3yaItYRQCzYZONrgRZLwiL/wEoncWydLDAACP4gC0TCpwEL87BuOKwXOPLr5 egyToaoqyVDYojwDhgCQ7fjsB3jisdqAy2Rww32IguhuHHuT7W9k8eKMXPUSN0331lWC b5iw==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1773845084; cv=none; d=google.com; s=arc-20240605; b=hi/qLxm7I6FvDPAecc79vN/VvX1Gr4WWxdSVNuOCKdHl4utl/HpraIlx+vNzw95nsw oXTv/DU7tUCmT/oKKn+vZZacgCEFMHmkqIfNoSVGCGSTbVdShk7mnXbzzsivgQEAvvRI TpBjBLKFliGstCj/DEcEnbfyZ16wGTR1MZaTJcvHPepZ2Qwq/2Cp98Md99ZRLe8/lVa1 nTBhsO15MT6GBvlCXHmBdNHtrmqgPRHCArqq63xTjOvC7EhLDhp1co/jmJoO0szG5Zvm RLFmET7s60zhTBS6RPIIIjJ1ii9wqDifTvYyG3Nk7Eg5k3CH+/TwqV9yxR+Rjx+AR/4/ 4+7g==
- Archived-at: <https://zsh.org/workers/54226>
- In-reply-to: <CAKiz1a_OLEGqSGpQ9wsVW_rriO35uiRfMkJV=FaOLAywyC3-qQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAKiz1a_OLEGqSGpQ9wsVW_rriO35uiRfMkJV=FaOLAywyC3-qQ@mail.gmail.com>
@@ -314,6 +317,7 @@ IPDEF2("HOME", home_gsu, PM_UNSET),
IPDEF2("TERM", term_gsu, PM_UNSET),
IPDEF2("TERMINFO", terminfo_gsu, PM_UNSET),
IPDEF2("TERMINFO_DIRS", terminfodirs_gsu, PM_UNSET),
+IPDEF2("ZSH_XTRACE_FILE", xtracefile_gsu, PM_UNSET),
IPDEF2("WORDCHARS", wordchars_gsu, 0),
IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT | PM_RESTRICTED),
IPDEF2("_", underscore_gsu, PM_DONTIMPORT),
This should probably be marked PM_DONTIMPORT so that you can't get zsh
to start spewing random text in any old file. (google shellshock for
why allowing this might be a bad idea)
@@ -1330,6 +1330,8 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
setsparam("ZSH_EXEPATH", metafy(mypath, -1, META_REALLOC));
}
}
+ if ((ptr = getsparam("ZSH_XTRACE_FILE")) && *ptr)
+ setsparam("ZSH_XTRACE_FILE", ztrdup(ptr));
if (cmd)
setsparam("ZSH_EXECUTION_STRING", ztrdup(cmd));
if (runscript)
What's the point of this? If the parameter is set, set it to its
current value? This is presumably not needed if we don't allow
importing the parameter, right?
+/* gsu.getfn for `ZSH_XTRACE_FILE' */
+/* gsu.setfn for `ZSH_XTRACE_FILE' */
useless comments
+ /* No exec-inherit, append for logs, alternate tty log IS thinkable. */
On Wed, Mar 18, 2026 at 3:08 PM Charles Blake <charlechaud@xxxxxxxxx> wrote:
>
> So, there seems to have been a stalled patch effort from Timothée
> Mazzucotelli on ZSH_XTRACEFD back in September 2020. Attached is a
> proposal that just uses a filename. mkfifo is always an alternative
> for more complex scenarios, but having the interface be a simple path
> seems more user-friendly to me.
>
> The patch is small and includes both docs and tests. It seems that
> the code to abstract `stderr` into `xtrerr` for trace log purposes
> has been around since a 2000-02-19 Peter Stephenson change. This new
> ZSH_XTRACE_FILE variable seems like a natural conclusion to that work.
>
> I don't think there are any file descriptor leaks. E.g., `for i in
> {1..50000};ZSH_XTRACE_FILE=/tmp/$i` works fine for me. An off-to-
> the side strace shows no increase in file descriptor numbers during
> such. As in the attached patch, the variable is not local-izable
> to shell functions. This may be a minor annoyance but does not seem
> like a deal-breaker problem since, in some sense, fd 2 for a process
> is already an "even more global" destination (ultimately the very
> motivation for a new destination for trace logs!).
>
> Let me know if you see any problems.
>
> Best,
> cblake
Messages sorted by:
Reverse Date,
Date,
Thread,
Author