# Shell Scripting Guides

# Set Up Shell Development Environment

Installation
-------------

```shell distribution="Debian"
sudo apt install shellcheck
```

# Shell Style Guide

#### Shell Script Heading

```shell
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2026 Tomáš Havlas <tomas@havlas.me>
```

##### Bash "Strict Mode"

```shell
set -euo pipefail
```

#### Error Log Function with Timestamp

```shell
function log() {
  echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
}

if ! do_something; then
  log "Unable to do_something"
  exit 1
fi
```

# Shell Snippet Collection

##### Write line same length as variable text

```shell
head -c "${#VARNAME}" </dev/zero | tr '\0' '-'
```