I'm running Ubuntu 10.10 with openbox running on top. I noticed today a command called caller, however there is no man page, it does not respond to any input (or --help) and whereis doesn't find it.

Any idea what it is?



type caller

and you will see it is a shell built-in. Running

help caller

will show its function, reported as well in bash's manual page. Briefly

Return the context of the current subroutine call.

  • 3
    Awesome. Not only did I learn what that command does, I also learn the "type" command. Thanks :) – user10065 Aug 24 '11 at 14:00
  • 2
    TIL bash has a built-in help command – nibot Aug 24 '11 at 17:55
  • Which I could upvote twice for teaching not only the answer but the process as well. – dmckee Aug 24 '11 at 18:36
  • @Muu, @nibot, @dmckee: also type type, type help, help type and help help could be fun to run :) – enzotib Aug 24 '11 at 18:48

The caller is builtin command (not specified by POSIX) appeared in Bash version 3.0 and it returns the context of any active subroutine call. See: Bash-Builtins for more reading.



If frame number is supplied as a non-negative integer, it displays the line number, subroutine name, and source file corresponding to that position in the current execution call stack.

Without any parameter, caller displays the line number and source filename of the current subroutine call.

Check the following Simple stack trace at Bash Hackers Wiki:


die() {
  local frame=0
  while caller $frame; do
  echo "$*"
  exit 1

f1() { die "*** an error occured ***"; }
f2() { f1; }
f3() { f2; }



12 f1 ./callertest.sh
13 f2 ./callertest.sh
14 f3 ./callertest.sh
16 main ./callertest.sh
*** an error occured ***

Here is sample of a decent die function to track down errors in moderately complex scripts:

{ bash /dev/stdin; } <<<$'f(){ g; }\ng(){ h; }\nh(){ while caller $((n++)); do :; done; }\nf'

For more sophisticated debugging, Bash extended debugging features are available and a number of special parameters that give more detail than caller (e.g. BASH_ARG{C,V}). Tools such as Bashdb can assist in using some of Bash's more advanced debug features.


It's a shell builtin command: man bash (Then search for 'caller')
It can be used to print a stack trace.

  • Thanks though I picked enzotib's answer as he also taught me 'type'. Many thanks though :) – user10065 Aug 24 '11 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy