Created
March 26, 2026 12:22
-
-
Save jonasgeiler/23a3970d15decabd0301f82d940291e8 to your computer and use it in GitHub Desktop.
A collection of various "strict mode" shell script snippets, inspired by http://redsymbol.net/articles/unofficial-bash-strict-mode/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/ash | |
| ###### STRICT MODE ###### | |
| # shellcheck enable=all | |
| IFS="$(printf ' \n\t')" | |
| set -euo pipefail | |
| ######################### | |
| # ... your script here ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ###### STRICT MODE ###### | |
| # shellcheck enable=all | |
| IFS=$' \n\t' | |
| set -euo pipefail | |
| ######################### | |
| # ... your script here ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ###### STRICT MODE ###### | |
| # shellcheck enable=all | |
| IFS="$(printf ' \n\t')" | |
| set -eu | |
| ######################### | |
| # ... your script here ... |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note
/bin/ashis the default shell of BusyBox/Alpine Linux.Use
strict-mode.ashif you're targeting BusyBox/Alpine Linux, like for Docker Images.