debugging a script??

Hi all,

Am working on a script to understand the flow control of it..
Since i am from a C background i looking out for an easy way to analyze the script as it runs ..

In C/C++ we have F7 that starts execution from main() and proceeds accordingly..
I was wondering if there is a same approach for shell scripts..

These are what i already tried..

bash -xv <script>
this is a little hard to understand (esp when the script itself runs into pages)
i tried understand function by function by using "set +x and set -x"
that was of little help..

so can anyone help me out on this??

Thanks

Debugging a shell script is entirely different than debugging a Visual C/C++ program. Sorry but there is no F7 available to help you. echo and print are you friends.

  1. You could use debuggers to debug a script - there are some available
  2. If you are trying to understand a script then this is not debugging it - unless someone created it correctly (indentation, comments, readable names, good code organization, etc.) you have to read it line by line or at least part by part. This is the same as with obfuscation and reading C code that you cannot compile to debug it :slight_smile:
1 Like