Bash.Builtin.Caller (Bash v0.6.0)

Copy Markdown View Source

caller [EXPR]

Returns the context of the current subroutine call.

Without EXPR, returns "$line $filename". With EXPR, returns "$line $subroutine $filename"; this extra information can be used to provide a stack trace.

The value of EXPR indicates how many call frames to go back before the current one; the top frame is frame 0.

Call Stack Entry Format

Each entry in the session's call_stack should be a map with:

  • :line_number - The line number where the function was called from
  • :function_name - The name of the function being called
  • :source_file - The source file containing the call

Exit Status

Returns 0 if the specified frame exists, 1 otherwise (including when not in a function).

Reference: https://cgit.git.savannah.gnu.org/cgit/bash.git/plain/builtins/caller.def?h=bash-5.3