[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LINENO is affected by where it is
From: |
Greg Wooledge |
Subject: |
Re: LINENO is affected by where it is |
Date: |
Sat, 4 Sep 2021 19:16:09 -0400 |
On Sat, Sep 04, 2021 at 04:04:05PM -0700, L A Walsh wrote:
> LINENO isn't the number of lines executed, but is the
> linenumber in the source file it is running in (or the line
> in a function for functions already in memory before you
> access it.
The OP of this thread replied to me that they sovled their problem. I
told them that it should be sent to the mailing list as well, but never
heard back from them after that. I can't tell whether their private
message to me was accidental or not.
Anyway, this looks like it was a bug in bash 5.0 which has been fixed
in bash 5.1.
unicorn:~$ cat foo
#!/usr/local/bin/bash-5.0
if true; then
echo "Point A: line #$LINENO"
(true)
echo "Point B: line #$LINENO"
fi
echo "Point C: line #$LINENO"
unicorn:~$ ./foo
Point A: line #4
Point B: line #6
Point C: line #6
unicorn:~$ bash-5.1 foo
Point A: line #4
Point B: line #6
Point C: line #8
This is my minimal reproducer, based on their note that the trigger is
an explicit subshell inside an "if". If the OP has anything else to add,
they can chime in.