Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.06 KB

README.md

File metadata and controls

58 lines (42 loc) · 1.06 KB

Bash Cheat Sheet

find . -name '*.sh' -print0 | xargs -0 shellcheck -s bash

Lib

My strict mode

#!/usr/bin/env bash
set -euo pipefail

rand-str

LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 64

Explained

shared_args

shared_args=(
  --some "$value_with_spaces"
  "$etc"
)

if condition
then shared_args+=(--more)
fi

command1 --args1 "${shared_args[@]}"
command2 --args2 "${shared_args[@]}"

Single square brackets silent bug

A=""
if [ -n "$A"]
then echo "not empty"
else echo "empty"
fi