Re: issue with debug trap

2023-12-18 Thread Martin D Kealey
On Sat, 16 Dec 2023 at 07:21, Giacomo Comes wrote: > debugon () { > trap 'if (($?)); then echo "$((LINENO-1)): $(sed -n "$((LINENO-1))p" > "$0")" ; fi' DEBUG > } > debugoff () { > trap '' DEBUG > } > > Although LINENO is the command that's about to be executed, that does not imply that LI

Re: issue with debug trap

2023-12-15 Thread Koichi Murase
2023年12月16日(土) 6:22 Giacomo Comes : The original post asks the reason for the difference in the status between the following two cases: if ((0)); then :; else echo "here \$? is 1"; fi if ((0)); then :; fi; echo "but here \$? is 0" and the answer is that the former returns the status of ((0)) (wh

Re: issue with debug trap

2023-12-15 Thread Kerin Millar
On Sat, 16 Dec 2023 00:09:10 + Kerin Millar wrote: > At this point, the value of $? is 1, prior to executing true - a simple > command. Just as for any other simple command, the trap code shall be > executed beforehand. Consequently, your test observes that $? is > arithmetically false and

Re: issue with debug trap

2023-12-15 Thread Kerin Millar
On Fri, 15 Dec 2023 17:21:23 -0400 Giacomo Comes wrote: > Hi, > I have stumbled upon a bug or something I don't understand while > using the debug trap. > Please run the script at the end. > When debug is turned on, during its execution the program > prints the line number and the line content wh