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 consider the following 6 line script: > > ------------------------------------------------ > > #!/bin/bash > > > > if ((1)); then > > ( : ) ; echo 1 $LINENO > > fi > > echo 2 $LINENO > > ------------------------------------------------ > > if executed it should print: > > 1 4 > > 2 6 > > And indeed that's the output if I run it on openSUSE Leap 15.5 > > (bash 4.4). However if I execute it on openSUSE tumbleweed > > (bash 5.2) the output is: > > 1 4 > > 2 5 > > I can't reproduce this. I get the correct (bash-4.4) results on bash-5.1 > and bash-5.2. There does seem to be a problem with bash-5.0, but it was > corrected in bash-5.1, according to my results. > > This is the case for both of your example scripts. > The script I was using was more complicated. I did simplify it and I tested the simpler version only with bash 5.0, assuming it would fail with 5.1 and 5.2 too. The following one fails with every 5.x version: ------------------------------------------------ #!/bin/bash
if ((1)); then ( : ) | : ; echo 1 $LINENO fi echo 2 $LINENO ------------------------------------------------ Need to add a pipe after the subshell command.