$BASH_LINENO  –  Line Numbers of Function Calls

$BASH_LINENO is an array and contains the line numbers, where a function defined in $FUNCNAME was invoked.

$LINENO contains the line number of the currently executing command.

Examples

Display execution position
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
a() {
  local i=$((${#FUNCNAME} - 1))
  cat << EOF
  file: ${BASH_SOURCE[i+1]}
  function: ${FUNCNAME[i]}
  executed at: ${BASH_LINENO[i]}
EOF
}
  
a
BashSupport Pro 是一个 支持 $BASH_LINENO 的 Bash 集成开发工具 – 马上试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款