This shows you the differences between two versions of the page.

Link to this comparison view

Next revision Both sides next revision
commands:builtin:caller [2010/09/22 05:51] external edit
commands:builtin:caller [2012/01/15 09:09]
ormaaj Some extra info off the top of my head - needs fact checking.
Line 56: Line 56:
 *** an error occured *** *** an error occured ***
 </​code>​ </​code>​
 +===== Notes =====
 +  * ''​caller''​ produces no output unless used within a script that's run from a real file. It isn't particularly useful for interactive use, but can be used to create a decent ''​die''​ function to track down errors in moderately complex scripts. <​code>​{ bash /dev/stdin; } <<<​$'​f(){ g; }\ng(){ h; }\nh(){ while caller $((n++)); do :; done; }\nf'</​code>​
 +  * 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 [[ http://​​|Bashdb ]] can assist in using some of Bash's more advanced debug features.
 +  * The Bash manpage and help text specifies that the argument to ''​caller''​ is an "​expr"​ (whatever that means). Only an integer is actually allowed, with no special interpretation of an "​expression"​ as far as we can tell.
 ===== Portability considerations ===== ===== Portability considerations =====
Line 62: Line 67:
 ===== See also ===== ===== See also =====
  • commands/builtin/caller.txt
  • Last modified: 2022/03/20 14:23
  • by sahirhoda