[Top][All Lists]

[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 (Windows/20100228)

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

    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() {
Ishtar:/tmp/d> echoln
Ishtar:/tmp/d> echoln
Ishtar:/tmp/d> echo $LINENO
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]