Comment by fzeindl
11 hours ago
My header on top of every script
#!/usr/bin/env bash
set -eEuo pipefail
# shellcheck disable=SC2034
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#######################################################
I'd suggest `pwd -P` to resolve symlinks too. (if you use DIR to call/source neighbouring scripts).
Wait... Most of my shell scripts have zero unused variables: I prefer to comment them if I may need them later on.
Why do you disable SC2034?
I don't think not having unused variables prevent me from doing things in my scripts!?
I understand if it's a preference but SC2034 is basically one of my biggest timesavers: in my case unused variables are typically a bug. Except, maybe, ANSI coloring variables at the top of the script.
I disable it only for the DIR variable which I might not use.