Programming Tutorials

caller in Mac OS X

By: Strauss K in macos Tutorials on 2011-02-03  

In Mac OS X, caller is not a standalone command like it is in some other operating systems. Instead, caller is a built-in shell command that is used within a Bash script to display the line number and source file of a function call in the call stack.

Here's an example of how to use caller within a Bash script:

#!/bin/bash

function foo() {
  bar
}

function bar() {
  caller 0
}

foo

When this script is executed, the output will be:

3 /path/to/script.sh

This indicates that the bar function was called from line 3 of the script script.sh.






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in macos )

Latest Articles (in macos)