DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

9 Tips For Writing Safer Shell Scripts

4 years ago levelup.gitconnected.com
9 Tips For Writing Safer Shell Scripts

Summary: This is a summary of an article originally published by the source. Read the full original article here →

Shell scripting is a powerful tool available on all platforms, even Windows, thanks to WSL. Many of them are considered safer than the shell defaults.

By default, a shell script is run entirely, regardless of any errors: By setting -e we can prevent the echo: There are certain exceptions to make it actually more usable: Never trip over unset variables ever again!

And thanks to shebangs we can use many different languages in scripts, given a suitable interpreter is available: Or we could always use a “compiles to single binary”-style language, like Golang or Rust.

hey are easy to use and integrate into our workflow, and shouldn’t be dismissed due to convenience, especially if others have to use our scripts.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com