From the course: Learning Bash Scripting (2022)

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Ensuring script portability

Ensuring script portability - Bash Tutorial

From the course: Learning Bash Scripting (2022)

Ensuring script portability

- [Instructor] In many cases, the scripts we write will be run on other people's computers, and that means we need to think about making them portable to ensure compatibility. Portability involves thinking about a few different facets of scripting. While many systems will have a reasonably recent version of Bash, it never hurts to check in the script to see if a version is close to what you expect. Older systems, and as I mentioned earlier, Macs, tend to have mostly old versions of Bash unless they've been specifically updated, and if you use newer language features, they won't work on older Bash installations. Bash gives you a few ways of checking the version when a script runs. There's two variables, BASH_VERSION and BASH_VERSINFO, they report a full version string and an integer representation of the major version respectively. We can easily test the BASH_VERSINFO variable to see if the major version of Bash is what…

Contents