Skip to content

Instantly share code, notes, and snippets.

@jonasgeiler
Created March 26, 2026 12:22
Show Gist options
  • Select an option

  • Save jonasgeiler/23a3970d15decabd0301f82d940291e8 to your computer and use it in GitHub Desktop.

Select an option

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/
#!/bin/ash
###### STRICT MODE ######
# shellcheck enable=all
IFS="$(printf ' \n\t')"
set -euo pipefail
#########################
# ... your script here ...
#!/usr/bin/env bash
###### STRICT MODE ######
# shellcheck enable=all
IFS=$' \n\t'
set -euo pipefail
#########################
# ... your script here ...
#!/bin/sh
###### STRICT MODE ######
# shellcheck enable=all
IFS="$(printf ' \n\t')"
set -eu
#########################
# ... your script here ...
@jonasgeiler
Copy link
Copy Markdown
Author

jonasgeiler commented Mar 26, 2026

Note

/bin/ash is the default shell of BusyBox/Alpine Linux.
Use strict-mode.ash if you're targeting BusyBox/Alpine Linux, like for Docker Images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment