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,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11273 invoked from network); 3 Sep 2021 17:39:14 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Sep 2021 17:39:14 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1630690754; b=AGrkjrunW9xQJYxaI9X2Ipqp26kV813QLGQpe6NuvPd5R/cQrE6Rl6bzW+rAI5aZ2Ku1IzfJyZ gVLbxFiEbI3von9I5DG/QrcadCMd4CV8rR9yvVqy5mwi6/aJq0rIlQOmLg1EhrY25K/QdfVrbf bdF95S0RoWMztqEwcc9rlZ3lY9RQWn7ZEqsA+2iR0vI9cqh59XUj8HPN+ag3+3Op1ohq9IMpZm rYkv//oDcOIJao5SnDkdgsjzYZiTyynoJVjCSBsUr8XcyZCzxPjl8nkPMbCajb0pE2ME+ADkyx LB61WuF7ELu/LhksKVLpdl5cvCbbkxG1r1PKljUBVei2Iw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f53.google.com) smtp.remote-ip=209.85.128.53; dkim=pass header.d=gmail.com header.s=20210112 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-20210803; t=1630690754; bh=JWUWLelMs6GaADHFwhgNZI379SG7/dJWbeyhj8qnufo=; 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=m+zkYWJr2VWzr6e9pr+Deqync2xUclO9yskzsg3GeB+cq/JHxGtWvCVmvekYbwpEyRY9/FpsdN QclHjFMKHzC8UX/5fcOeJv/n3gbG6m3iS9vAxD6aNHJWTkBakXawc2OblIWhMoRc7ErG4D+39g 32hkJCK94J7KFDhfE/1UUMhizbIWY2mxPY+Q5k6sipkPEGYyshThzEbml9R0q4p50p3MOyXdqt uo0qgQuJK2Vvp2Vf5KXz9AKMs7X9WQb2lt0z2jeWqpBGFNiRf4R/XoHp2epatC+RwHXevt/JL6 KmDYSqsmwsDdd7wKGIgO3mW3hco+MIooMOi7LWX0c8oyuw==; 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=RwN287tB1lbrIsOcCy+OvFBihLvyL1KZSsV1zTsd6Qw=; b=lDDn/F5gidMUco3kH5sIwNRmyw 7r0RKSCWwbdwksLUer6cWyHBkDoK8CEXtF/haRW9v2xxggWQ8KWLB4yoPqXd937sACUv6pgIQCyMK mUYGvndsOUOuuoXxjYtgo/k8TsXmJb7G/RveISWIh85HdA9RtrfYUZxhUbtjBOtISGjHvQqYXZ9z5 Emkm1jf8yTw0RD4b3fsUrtvqSoqs2ip6HToJmcuwswHY72NP+bAytfP+TtTLV/4rbQogZ1PaIWt/E sgXxJts/w+P+elgY/4+BTF8Cqp1WI1yu8uXMm+GQGpsGLoTmP/GJ8xJWXA5dhkH/gSbL4PayxqXod 7JjhWEMA==; Received: from authenticated user by zero.zsh.org with local id 1mMD9m-000FkQ-OJ; Fri, 03 Sep 2021 17:39:14 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f53.google.com) smtp.remote-ip=209.85.128.53; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f53.google.com ([209.85.128.53]:33447) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mMD8x-000EaK-Hg; Fri, 03 Sep 2021 17:38:24 +0000 Received: by mail-wm1-f53.google.com with SMTP id 192-20020a1c04c9000000b002f7a4ab0a49so75687wme.0 for ; Fri, 03 Sep 2021 10:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RwN287tB1lbrIsOcCy+OvFBihLvyL1KZSsV1zTsd6Qw=; b=L15vwCS9cAcGMsweaLDdrfkvdOvDXR9Tzbkwfqqez6AKRfNFjiLtMO2ZEnge+zfzKz AScPPdYBGo/qJsuepKz11VsgBeiny+l0m/H1fnkyeD3dKLDejYCoMTW/u4dMgVuwsipb IANQjw6PrGxkOKq35IO705If7lMP65NSusG1B0M7DQAkKzC3rCW/2yngNarfCNVGq7gC QVjhQEsB3rbtAsFSTw8tyqkq0uM+uNXsYsIGCXljL8pNRFtzwCMrhabvgUy1TagXbUoS Iqbwb4LNJUVy80igGQIlDtQQlKhtANGWaXYMl5BhtPRiYU98dP9UPieL/7JDQ6tpXxob 1K5A== 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=RwN287tB1lbrIsOcCy+OvFBihLvyL1KZSsV1zTsd6Qw=; b=gn4tIMBufFlmYDOWopAWGkX/k0kpRxzJEMEkJJuSQM4JAxvVq3fXDlTfWmzFEM88I0 J/xoM9i+vr2OeKAH6Z09POgwayD3eD5BQ79sxr2+Bwc7Fok6EvXjkYBLu5fcbXsy7GQq GY5twT13p1DIyehj6N+3SzmiBMx8I0h7JY0be/qlyUnda6qVICxc2zXPmleJ/kqAtiVy UsQdsTAgX2zX5fE/SKUUk09qBLXo1azTr0pI0e8kDhnR2q63aUWmqrYGGmIm7bg8YOIA PNJo3I5/yZsBHQK8XVu9a5Bn2Bhph1fwk8C11A/2iZ80qMkyzK9aTBw1W9nu/ZGRHwin EN9g== X-Gm-Message-State: AOAM530I0I86+YgZy6OP4TENlzp0sPMk85EawgYPiPoG9CZuk3La2zgk f+7jZAz5/XcxgOYWvvWByIinu9+Kb8Ky+fMy9E0rUU2Ux3U= X-Google-Smtp-Source: ABdhPJyGEYbF9nYAkh4AMTz4iq31oZBGWwxaRQ1YEl5JubznDoUUciZlVoiHsH4cWGp4rWgkpj0l3jSCwY2JnwrVsDc= X-Received: by 2002:a7b:c843:: with SMTP id c3mr23103wml.76.1630690703043; Fri, 03 Sep 2021 10:38:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zach Riggle Date: Fri, 3 Sep 2021 12:38:12 -0500 Message-ID: Subject: Re: Accessing the evaluated expression which caused an error To: Bart Schaefer Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27080 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: > What exactly might you want captured? Very frequently I build a create an array that contains a command, e.g. declare -a cmd=( echo hello world ) And invoke it like: "${cmd[@]}" When I xtrace, it will print out the values inside the array. +wat.sh:2> cmd=( echo hello world ) +wat.sh:3> echo hello world With TRAPDEBUG or TRAPERR, all I get is the "${cmd[@]}". None of the Zsh-supplied arrays (funcfilesource etc.) contain that. I originally had some hope that $_ would work, but it appears not to. Zach Riggle On Fri, Sep 3, 2021 at 12:14 PM Bart Schaefer wrote: > > On Thu, Sep 2, 2021 at 6:43 PM Zach Riggle wrote: > > > > I'm aware of funcsourcetrace, funcstack, and TRAPDEBUG / > > ZSH_DEBUG_CMD as well, but none of these contain the actual expression > > evaluated -- just the input to zsh. > > > > I know that zsh has the data internally, since "zsh -x" shows the > > fully-evaluated expression, so that data must be available somewhere, > > even if it's not exposed in a shell variable. > > Hm. What xtrace does is dump each individual shell word ... it just > happens to dump them in the order that puts them together as an > "expression". But you'll notice it's not actually an expression, it's > just e.g. a single simple command. In fact it's even a bit weird for > some structured commands (look at the output for a "case" statement > for example). > > It's correct that none of this is captured in any sort of format that > would be usable by a shell script. It never exists all at once in > such a format internally. > > What exactly might you want captured?