Writing Robust Bash Scripts
Offered By: Linux Foundation via YouTube
Course Description
Overview
Learn to create reliable and efficient Bash scripts in this 21-minute conference talk by Leonardo Gutierrez Ramirez from AutoZone. Explore common pitfalls and best practices, including choosing the appropriate shebang, using 'checkbashisms' for POSIX compliance, implementing set -o pipefail, and utilizing local variables in functions. Discover the importance of proper error handling in cron jobs, explicit exit codes, and leveraging tools like www.shellcheck.net for script analysis. Enhance your scripting skills to write more robust and maintainable Bash scripts for various applications.
Syllabus
S OPIN SOURCE SUMMIT Writing Robust Bash Scripts
What can go wrong here?
Choose a shebang (#!) carefully ...
If you are coding in bash then use the bash shebang
If you want to create a POSIX script use 'checkbashisms' script to check your script for bashisms
Use set -o pipefail
Use local for variables in functions Variables in bash have global scope
Cron Jobs: "SILENCE IS GOLDEN" What can go wrong with the following code if the script triggers errors that are not redirected properly?
Exit your scripts with an explicit exit (n 0) on any non-normal exit
Use www.shellcheck.net Shell Script analysis tool
Taught by
Linux Foundation
Tags
Related Courses
Essentials of Linux System AdministrationLinux Foundation via edX Raspberry Pi Workshop 2018 Become a Coder / Maker / Inventor
Udemy 2024 Linux Masterclass: All You Need To Know To Get a Job
Udemy Learn Linux Administration and Supercharge Your Career
Udemy Complete Linux Training Course to Get Your Dream IT Job 2024
Udemy