line numbers are false after (...) || {...}
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security uname output: Linux mamita 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.0 Patch Level: 3 Release Status: release Description: After the below described construct, the line numbers are off, this affects both the envvar LINENO and the line numbers bash writes on an error. It seems that the newlines in {} are ignored, if it is after "() ||" or "() &&" . Also tested with `true || { ... }` and { ... } || { ... } . In those cases the correct line numbers are shown. Repeat-By: #!/bin/bash ( echo foo; ) || { echo bar # 4.line echo bar # 5.line } # 6.line echo lineno: $LINENO # 7.line [[ -e bla]] # 8.line output: foo lineno: 4 ./tester.sh: line 5: unexpected EOF while looking for `]]' ./tester.sh: line 6: syntax error: unexpected end of file => The reported line-numbers are 2 lines off.
Re: line numbers are false after (...) || {...}
i guess this is cause the code u wrote didnt get executed so it didnt count On Thu, Oct 21, 2021, 16:17 kovacs istvan wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -g -O2 > -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=. -fstack-protector-strong > -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security > uname output: Linux mamita 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 > (2021-07-18) x86_64 GNU/Linux > Machine Type: x86_64-pc-linux-gnu > > Bash Version: 5.0 > Patch Level: 3 > Release Status: release > > Description: > After the below described construct, the line numbers are off, this > affects both the envvar LINENO and the line numbers bash writes on an error. > > It seems that the newlines in {} are ignored, if it is after "() ||" or > "() &&" . > > > > Also tested with `true || { ... }` and { ... } || { ... } . In those cases > the correct line numbers are shown. > > Repeat-By: > #!/bin/bash > > ( echo foo; ) || { > echo bar# 4.line > echo bar# 5.line > } # 6.line > echo lineno: $LINENO # 7.line > [[ -e bla]] # 8.line > > output: > > foo > lineno: 4 > ./tester.sh: line 5: unexpected EOF while looking for `]]' > ./tester.sh: line 6: syntax error: unexpected end of file > > > > => The reported line-numbers are 2 lines off. >
Re: line numbers are false after (...) || {...}
This has been fixed in bash5.1 bash-5.1$ cat ~/tester #!/bin/bash ( echo foo; ) || { echo bar# 4.line echo bar# 5.line } # 6.line echo lineno: $LINENO # 7.line [[ -e bla]] # 8.line bash-5.1$ ~/tester foo lineno: 7 /home/emanuele6/tester: line 8: unexpected EOF while looking for `]]' /home/emanuele6/tester: line 9: syntax error: unexpected end of file On 21/10/2021, kovacs istvan wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=. > -fstack-protector-strong -Wformat -Werror=format-security -Wall > -Wno-parentheses -Wno-format-security > uname output: Linux mamita 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 > (2021-07-18) x86_64 GNU/Linux > Machine Type: x86_64-pc-linux-gnu > > Bash Version: 5.0 > Patch Level: 3 > Release Status: release > > Description: > After the below described construct, the line numbers are off, this affects > both the envvar LINENO and the line numbers bash writes on an error. > > It seems that the newlines in {} are ignored, if it is after "() ||" or "() > &&" . > > > > Also tested with `true || { ... }` and { ... } || { ... } . In those cases > the correct line numbers are shown. > > Repeat-By: > #!/bin/bash > > ( echo foo; ) || { > echo bar # 4.line > echo bar # 5.line > } # 6.line > echo lineno: $LINENO # 7.line > [[ -e bla]] # 8.line > > output: > > foo > lineno: 4 > ./tester.sh: line 5: unexpected EOF while looking for `]]' > ./tester.sh: line 6: syntax error: unexpected end of file > > > > => The reported line-numbers are 2 lines off. >