From the course: Troubleshooting and Debugging Bash

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Testing functions

Testing functions - Bash Tutorial

From the course: Troubleshooting and Debugging Bash

Start my 1-month free trial

Testing functions

- [Instructor] If you have failing functions, try running them on their own to see where a failure might be. If you've written a complex script with multiple functions, and you don't know which ones are failing, or if you've been handed a script with multiple functions that are failing and you have no idea why, it could be very helpful to open the script, take the functions out, and paste them into their own script. This won't always work as sometimes functions have dependencies elsewhere in the script but if the functions were written to be self contained, then each one should function independently in an outside testing script. You can test the output of a function by simply running it on its own. You can also test whether or not a command will work on the command line manually if you want to see if a command is within your script that will work at all. This is very similar to an earlier described troubleshooting…

Contents