install: fix shellcheck warnings & errors

This commit is contained in:
Fernando Schauenburg 2023-02-26 17:38:24 +01:00
parent 3cecc0998d
commit 77d189a846

View file

@ -4,7 +4,9 @@ set -e
DOTFILES="$(dirname "$(realpath "$0")")" DOTFILES="$(dirname "$(realpath "$0")")"
TARGET="$HOME" TARGET="$HOME"
# shellcheck disable=SC1091 # don't complain about following config.local
[ -r "$DOTFILES/config.local" ] && . "$DOTFILES/config.local" [ -r "$DOTFILES/config.local" ] && . "$DOTFILES/config.local"
GIT_USER="${GIT_USER:-Fernando Schauenburg}" GIT_USER="${GIT_USER:-Fernando Schauenburg}"
GIT_EMAIL="${GIT_EMAIL:-dev@schauenburg.me}" GIT_EMAIL="${GIT_EMAIL:-dev@schauenburg.me}"
@ -46,16 +48,16 @@ greeting() {
info " Target: $cyan$TARGET$rst" info " Target: $cyan$TARGET$rst"
info " Git user: $green$GIT_USER <$GIT_EMAIL>$rst" info " Git user: $green$GIT_USER <$GIT_EMAIL>$rst"
if [ -t 0 -a -t 1 ]; then if [ -t 0 ] && [ -t 1 ]; then
info info
info "Press ENTER to continue (CTRL-C to cancel)..." info "Press ENTER to continue (CTRL-C to cancel)..."
read k read -r
fi fi
} }
make_dirs() { make_dirs() {
heading 'create auxiliary directories' heading 'create auxiliary directories'
while read item; do while read -r item; do
dir="$TARGET/$item" dir="$TARGET/$item"
if [ ! -d "$dir" ]; then if [ ! -d "$dir" ]; then
echo "${yellow}MKDIR:$rst $dir" echo "${yellow}MKDIR:$rst $dir"
@ -162,16 +164,16 @@ fi
dry_run() { [ -n "$IS_DRY_RUN" ]; } dry_run() { [ -n "$IS_DRY_RUN" ]; }
usage() { usage() {
echo "Usage: $(basename $0) [-h] [-f] [-t <target>]" echo "Usage: $(basename "$0") [-h] [-f] [-t <target>]"
echo "" echo ""
echo " -h print this help and exit" echo " -h print this help and exit"
echo " -f modify filesystem rather than dry run" echo " -f modify filesystem rather than dry run"
echo " -t set <target> directory (default: \$HOME)" echo " -t set <target> directory (default: \$HOME)"
} }
heading() { printf '%s\n' "${blue}===== $1 ==========${rst}"; } heading() { echo "${blue}===== $1 ==========${rst}"; }
info() { printf '%s ' "$@"; printf '\n'; } info() { echo "$*"; }
warn() { printf '%s ' "${yellow}$@${rst}"; printf '\n'; } warn() { echo "${yellow}$*${rst}"; }
error() { printf '%s ' "${red}$@${rst}"; printf '\n'; } error() { echo "${red}$*${rst}"; }
main "$@" main "$@"