issue with debug trap

2023-12-15 Thread Giacomo Comes
owever the previous: if ((0)); then : fi (without the else clause) does not cause a non zero return value. Is this the expected behavior (and if yes why)? Or is it a bug? Seen in bash 4.4 and 5.2. Giacomo Comes #!/bin/bash debugon () { trap 'if (($?)); then echo "$((LINENO

Re: unreliable value of LINENO variable

2023-12-04 Thread Giacomo Comes
On Mon, Dec 04, 2023 at 12:21:11PM -0500, Chet Ramey wrote: > On 12/4/23 8:46 AM, Giacomo Comes wrote: > > I use often the value of LINEO in order > > to know where to look for issues in a script. > > Recently I discovered a bug. > > > > Please con

unreliable value of LINENO variable

2023-12-04 Thread Giacomo Comes
I use often the value of LINEO in order to know where to look for issues in a script. Recently I discovered a bug. Please consider the following 6 line script: #!/bin/bash if ((1)); then ( : ) ; echo 1 $LINENO fi echo 2 $LINENO -