← All insightsBest Practices

Bash & Shell Scripting best practices for teams

Nir Geier, CodeWizard · 26 January 2026 · 3 min read · Intermediate

Bash & Shell Scripting rewards a little discipline. These are the practices that keep it maintainable as a team and a codebase grow.

The practices

  • Start every script with set -Eeuo pipefail and an ERR trap
  • Quote all variable expansions; prefer [[ ]] over [ ]
  • Run shellcheck and shfmt in CI

What good looks like

A safe script skeleton with strict mode and a trap.

bash
#!/usr/bin/env bash
set -Eeuo pipefail
trap 'echo "error on line $LINENO" >&2' ERR

main() {
  local name="${1:?usage: deploy <name>}"
  echo "deploying ${name}"
}
main "$@"

Anti-patterns to retire

  • No set -euo pipefail, so failures are silently ignored
  • Unquoted variables that break on spaces and globs
  • Parsing ls output or using eval on untrusted input

Want senior help putting Bash & Shell Scripting to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult