|
From: | Chet Ramey |
Subject: | Re: Function declarations produce no trace nor trigger debug trap while having side effects |
Date: | Mon, 31 Oct 2022 14:46:13 -0400 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 |
On 10/28/22 12:09 PM, Erik Adelbert wrote:
Hello Chet and other bash maintainers, Thanks for your time.On 27 Oct 2022, at 23:26, Chet Ramey <chet.ramey@case.edu <mailto:chet.ramey@case.edu>> wrote:we believe the current semantic to be at least unclear and would like to see either:0 the DEBUG trap called _before_ any function declaration (preferred)While calling the DEBUG trap before certain compound commands has value, I don't think that function definition commands rise to that level.In the demonstrated case (2nd example of our report), we made clear that commenting in/out a function definition *seemed* to make an unrelated error appear/disappear from the debugging support because it was in the vicinity.
There are a couple of ways to overcome that. You could save and restore the value of $? around a function declaration, or you could reorder code so that function definitions come before the command whose exit status you're interested in. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
[Prev in Thread] | Current Thread | [Next in Thread] |