bug-bash
[Top][All Lists]
Advanced

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

bottom of ${BASH_LINENO[*]} stack is always '0'


From: bill-auger
Subject: bottom of ${BASH_LINENO[*]} stack is always '0'
Date: Tue, 21 Feb 2023 16:33:31 -0500

the bottom of the ${BASH_LINENO[*]} stack is always '0'; and the
array never contains the line number of the actual call site, as
${LINENO} does - is that expected behavior?

im not sure if this is a bug or not - it seems like a bug to me
though - the '0' value is meaningless and useless, yes?


$ cat ./bash_lineno.sh 
#!/bin/bash

echo "[LOC_${LINENO} ]: ${BASH_LINENO[@]}"

f1()
{
  echo "[LOC_${LINENO} ]: ${BASH_LINENO[@]}"
  f2 # LOC_8
}

f2()
{
  echo "[LOC_${LINENO}]: ${BASH_LINENO[@]}"
}

f1 # LOC_16

echo "[LOC_${LINENO}]: ${BASH_LINENO[@]}"


$ ./bash_lineno.sh
[LOC_3 ]: 0
[LOC_7 ]: 16 0
[LOC_13]: 8 16 0
[LOC_18]: 0


$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)



reply via email to

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