Bash scripts are extremely handy when mostly dealing with Linux commands, such as find, grep, sed, and so on. One can write functions, just like in any other languages. However, I have to admit that I haven't really dealt with Bash scripting much so far. One of the reasons, I suppose, is that it is difficult to debug Bash scripts. I didn't think there was any debugging tool for Bash. Well, I just realized that I was wrong! There is in fact a very nice debugger for Bash: bashdb
To install, you can run the following on macOS
$ brew install bashdb
or the following for Ubuntu
$ sudo apt-get install bashdb
To start debugging, run
$ bashdb bash_script.sh argument1 argument2 ...
Many of the commands are similar to that of gdb, but for more info, type in help. Also, this documentation can be of great reference.
Happy bashing!
No comments:
Post a Comment