Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So here I have a simple function that I wish to debug. However, I am unable to debug the desired function even with set -o functrace enabled. Before resorting to asking this question, I had managed to find a possible solution that did not produce the desired results, which is located here.

How can I get bash debug my functions?

echo "Hello World"
hello() {
    echo "Hello world"


user@mac11:53:29~/desktop bash -x debug.sh 
+ echo 'Hello World'
Hello World
share|improve this question

closed as too localized by manatwork, Anthon, Mat, jasonwryan, vonbrand Jun 9 '13 at 19:47

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

In the example code, function hello is never called. – demure Jun 9 '13 at 16:47
up vote 3 down vote accepted

but that answer in the link does seem to work ........

  Kaizen ~/so_test $ cat zhello.sh
  set -x ;
  set -o functrace

   echo "Hello , how are you $name";

 hello "itin" ;

output is :

 Kaizen ~/so_test $ ./zhello.sh
  + ./zhello.sh                     --  script was run 
 ++ set -o functrace
 ++ hello itin                      -- function was invoked
 ++ name=itin                       -- variable assigned within the function hello 
 ++ echo 'Hello , how are you itin'
 Hello , how are you itin           -- printed the output from the function ...

I am a bit curious , is there something specific you looking for ?

share|improve this answer
I forgot to call it. Sorry, I'm new to the whole bash scripting thing. – Brandon D. Jun 9 '13 at 16:56
@BrandonD , no problem .... all this helps learn !! – n13 Jun 9 '13 at 17:01

The function hello() was not called at the end of script. User error.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.