From the course: Troubleshooting and Debugging Bash
Collapse code - Bash Tutorial
From the course: Troubleshooting and Debugging Bash
Collapse code
- [Instructor] When you build functions, those code elements can become quite long. And it can be hard to read your script easily. When your script gets sophisticated enough to start building conditional statements and functions into your script, it can become difficult to read. A BASH script is not intended to be very long. In contrast, writing entire applications in a programming language will lead to programs with incredibly lengthy and complex interconnected and interdependent files. BASH scripts should never be as complicated as a program would be. For this reason, the tools available to you within BASH to deal with many lines of code are not as robust as those you would encounter in something like Python or Ruby. A good text editor, however, will recognize code segments in BASH like conditional statements that can be collapsed to free up additional screen space. Collapsible code in a script editor allows you to shrink functions into smaller spaces on screen, making it easier for you to keep track of what you're doing. When a BASH script becomes too large to keep track of visually, you've probably reached a point where you should shift to a different language like Python or move to a programming language and look at possibly building an actual application instead. Whatever you choose, when a BASH script is so long that you're losing track of what's going on, you may want to move your project into a different environment that is better suited to larger projects.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.