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=-2.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11122 invoked from network); 29 Nov 2021 16:00:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Nov 2021 16:00:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1638201655; b=TXenwCFH6pZSqIB6Ly9cseWJBvSMkqamE0yXYhvRxVopjc1D2KwTSxpmbfMs8Qokskagi8PZhg eR9WT5ndyt7GuYvtIOnFDcWEthsukuwkQp0yLWFtFTy3pPQox6QD7iLJTtmF9qcTToJfxUqbX7 4t1YxAHoztdpQeh7gKcC+AU0GeQ6GraKf6yI1D5YV+EGSfdXBuN8R94xBmfn6gzl1XzY0lmRRv mTemMGnbOW84ZkaACgJwW2lST6pN6hxWgkZwl5b5bCeHx6RhNIicJUIjHYiZ2iJb9QrgkAJHOK QhhnRRjrELxexrWL2gHYd9ZJVhwU1/zrgQVflNYuDX7ZFg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1638201655; bh=cd5c6D63KM7wRH+VLBz0LmqXRfrbEQEKk2i8v+Akwzo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=nQr3cA9L5fGuU1wXAWhAVOrRQ12E4jDCp7ek6x30iDH+KIlw1Gg0RtlNJZA8kz24It0pkri6f9 FY8/zjTz8Q5BoNoyh72WDgd4d8lprEE/wBgqbjCZcLqv/QHoZgvE4Oc2EutdoSk9UzWuMusZ1l lAYHgYSQU9EgvkbywPOG0y6qVtIjmgT5SwIO6SLL3mcLd/Iwv2cbvRpqNI5RXatJ0pTdqKAOUq e6/EjLmyxhx1p+fvVNZTKSqLee6wyrya/QsE8ZRehi1KPwjdC0LsbyGP/0evyQfL8suw8RHIgU Zd/i81xdckBJTqO7DHbPkyIC2XMaupL9hHMfZ1B4bdWwBw==; 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-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=kx/lAwritHBt+BzmpWNNNCijSSC7eZWV+gD8u8MHHDo=; b=MQB02nse/5dgFE7KDiMmTkYeOi kHy/pPsWAtllD4kGhSh6w4Mv+Ta2UJfpT8YBn48C5z4jpyWvRsfvPu9WWGHEu6nHMjiNciOOqmoK1 NbzRxlUxvqmz+nOget1lF7ngRLSZWuekCpJ4CX1v4eqBOS2da4LNh0s9M0dU3TkUUEsa+eiKdQmzh ct0P4T+OWxWWSilzlxBNOgFtlQxQwrTRqrQKW3xyANWZrzU0t59ydOmjDMgAUmk/2+Z+xMLFqbhBL 7TdaGmEedkT5nOt1y+sIxAZsWbFoiZmN7pUKGT+7pQKCdi6Jm7II93geTUaTHDv42nsPluz/L0syb 8IyuPMzw==; Received: from authenticated user by zero.zsh.org with local id 1mrj5K-000OuS-Qr; Mon, 29 Nov 2021 16:00:54 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:45084) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1mrj4X-000ODt-Nn; Mon, 29 Nov 2021 16:00:07 +0000 Received: from [212.54.57.82] (helo=smtp3.tb.ukmail.iss.as9143.net) by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1) (envelope-from ) id 1mrj4X-0007hc-BL for zsh-users@zsh.org; Mon, 29 Nov 2021 17:00:05 +0100 Received: from oxbe8.tb.ukmail.iss.as9143.net ([172.25.160.139]) by smtp3.tb.ukmail.iss.as9143.net with ESMTP id rj4Xm7l2HiBAerj4XmX7Rr; Mon, 29 Nov 2021 17:00:05 +0100 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-users@zsh.org X-SourceIP: 172.25.160.139 X-CNFS-Analysis: v=2.4 cv=S9LKfagP c=1 sm=1 tr=0 ts=61a4f905 cx=a_exe a=pgSR3NrKiwmx/6vnWRL19w==:117 a=I_Av47A-8eYA:10 a=IkcTkHD0fZMA:10 a=vinPr5In5y8A:10 a=q2GGsy2AAAAA:8 a=_XDTy7I-ZOq8wVHz24QA:9 a=QEXdDO2ut3YA:10 a=z9dJwno5l634igLiVhy-:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1638201605; bh=cd5c6D63KM7wRH+VLBz0LmqXRfrbEQEKk2i8v+Akwzo=; h=Date:From:To:In-Reply-To:References:Subject; b=fYEhq9slIR4Z+6miMqMdRPFR5C+E73SgSYA3N9ni0gZWTC4ZX87CyJR95pLQTdIuB Jri8OZjSLsMkcBGpu3EREy/EadGaS3QlyFOHvH61uKI4LvEFx8VePMhLfPFjRtfBkZ j3v6wVo4FGw1FimYEAe5DSp0hTkJDDOab7HXbcmuRB6X6qtrA4gFKhLr1xFZQfIpEd LUFVu3XFnbWsq0qbwAY9jiCfjTPNS4Lz+rqt2olTsOiVntc3Rn7gM84jJhRkjq8BxY DiMvhU/Z6k9eJDkx60gOhbAqY3g96QUh0j2VwZpPRfKc/2+qe9S5l10Qc8ZL/eOgKn eA7FKGQH6jznA== Date: Mon, 29 Nov 2021 16:00:05 +0000 (GMT) From: Peter Stephenson To: Zsh Users Message-ID: <272260155.566740.1638201605055@mail2.virginmedia.com> In-Reply-To: References: Subject: Re: Source mangling in $functions_source and typeset -f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 165.225.17.146 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfG7nBFj+GfA06rgGCIoR5nSBQr9RrVckqpuPmRN3J96Ihm+XDOo5J8O5xyrgkavPdAzkNKPp+Wn1UpSqrvchkF9GiPUkkHMKDYbBLQjkiGgU+LtXVZ/a QUXXOo7ZgbrsqEmhqY0FfkKmsLsxPC4QE9NqRUHSFe0pv0RwVFqpjfOS9lEX4H5z7EsgmSJ4xDgkAc/Rb8NDyQUdNfrvVCARf/0alW2iQsM3eTjx6aMkOj5x X-Seq: 27383 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 27 November 2021 at 17:47 Bart Schaefer wrote: > > Is there a convenient way, from within zsh, to get either: > > > > The original, unmodified source of a function (autoloaded or otherwise) > > The line offsets in the file where the function is defined (if any)? > > The parse tree only tracks the line numbers of executable code, so as > to be able to update the LINENO variable and print line numbers in > debug traces and prompts. The line number of the closing brace isn't > recorded (in fact it's possible to define a function without any open > or close brace if the body is a single expression). > > So, strictly speaking, no, neither of those. Actually, the original line number is remembered, and can be output using a prompt --- typically PS4. See the zshmisc manual and the description of prompt escapes. %i The line number currently being executed in the script, sourced file, or shell function given by %N. This is most useful for debugging as part of $PS4. %I The line number currently being executed in the file %x. This is similar to %i, but the line number is always a line number in the file where the code was defined, even if the code is a shell function. So, for example, my precmd is defined in .zshrc from line 297 and if I edit PS4 to %e:%N:%i(%I)> then I get output lines with "set -x" like +1:precmd:2(299)> integer new_status=0 I don't think there's any way of getting this information without actually executing the code, though. pws