Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15083

$LINENO in a bash script using subshells in if statements

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From charles.deledalle@gmail.com
Newsgroups gnu.bash.bug
Subject $LINENO in a bash script using subshells in if statements
Date Fri, 5 Jul 2019 15:30:20 -0700 (PDT)
Lines 39
Approved bug-bash@gnu.org
Message-ID <mailman.265.1562375954.2688.bug-bash@gnu.org> (permalink)
References <20190705223020.2AF67C61CA9@denver>
NNTP-Posting-Host lists.gnu.org
X-Trace usenet.stanford.edu 1562375957 21505 209.51.188.17 (6 Jul 2019 01:19:17 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 137.110.39.13
X-Mailman-Approved-At Fri, 05 Jul 2019 21:19:13 -0400
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20190705223020.2AF67C61CA9@denver>
Xref csiph.com gnu.bash.bug:15083

Show key headers only | View raw


Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-LQgi2O/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security
uname output: Linux denver 5.0.0-16-generic #17-Ubuntu SMP Wed May 15 10:52:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 3
Release Status: release

Description:
	Using a subshell environment in an if statement screws up my $LINENO variable, see minimal reproducible code below.
	The problem occurs only if the condition is true (meaning the subshell is executed). Same problem occurs if the subshell is in a while/for loop iterating at least once.
	The problem occurs with Bash 5.0.3. It does not occur with 4.2.3 or 3.2.57. See discussion here: https://stackoverflow.com/questions/56909685/weird-behavior-of-lineno-in-a-bash-script-using-subshells-in-if-statements

Repeat-By:
	Here is the minimal reproducible code

	1. #!/bin/bash
	2. if true ; then
	3.     (echo dummy)
	4. fi
	5. echo "Line no:" $LINENO

	Shows "Line no: 4" instead of 5.

Fix:
	Problem can be fixed as

	1. #!/bin/bash
	2. (if true ; then
	3.     (echo dummy)
	4. fi)
	5. echo "Line no:" $LINENO

	but this is quite a hugly workaround.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

$LINENO in a bash script using subshells in if statements charles.deledalle@gmail.com - 2019-07-05 15:30 -0700

csiph-web