help-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: Thu, 9 Feb 2023 14:42:53 -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?

posting to this list; because im not sure if this is a bug or not
- it seems like a bug to me though - obviously the '0' value is
meaningless


$ 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)


system is parabola x86_64 (archlinux)



reply via email to

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