Skip to main content

Shell Style Guide

Shell Script Heading

#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2026 Tomáš Havlas <tomas@havlas.me>
Bash "Strict Mode"
set -euo pipefail

Error Log Function with Timestamp

function log() {
  echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
}

if ! do_something; then
  log "Unable to do_something"
  exit 1
fi