bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LINENO is affected by where it is


From: L A Walsh
Subject: Re: LINENO is affected by where it is
Date: Sat, 04 Sep 2021 16:04:05 -0700
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)



On 2021/09/01 02:36, David Collier wrote:
Version:

    GNU bash, version 5.0.3(1)-release (arm-unknown-linux-gnueabihf)

Raspberry Pi using Raspbian.

Installed from repo?

LINENO goes backwards when run sync
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.  Some examples:

Ishtar:/tmp/d> echoln() {
 echo "LINENO=$LINENO"
 }
Ishtar:/tmp/d> echoln
LINENO=1
Ishtar:/tmp/d> echoln
LINENO=1
Ishtar:/tmp/d> echo $LINENO
262
Ishtar:/tmp/d> saveln="val of lineno=$LINENO"
Ishtar:/tmp/d> echo run some stuff
run some stuff
Ishtar:/tmp/d> echo "lineno=$LINENO, not $saveln"
lineno=265, not val of lineno=263
----

echo "================== At this point \$LINENO has correctly counted
---
LINENO doesn't "count", it is a passive 'count' of  where
you used the variable "LINENO" (based on some restrictions, like
resetting to 1 in functions).


Does that clarify anything?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]