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

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /