From b9f0f0109996320fab5e5ff0d8a4d2d6dfa8fb6b Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sat, 14 Feb 2026 22:28:47 -0500 Subject: [PATCH] Update setup script. --- setup.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index cd3c219..7f71932 100755 --- a/setup.sh +++ b/setup.sh @@ -1,7 +1,29 @@ #!/usr/bin/env bash -git submodule update --init +set -Eeuo pipefail + +# $1: Error message +# $2: Error code +function fatal() { + local msg=${1:-"Unspecified error"} + echo "[Error:$LINENO] Could not install dotfiles: $msg" + exit ${2:-1} +} +trap 'fatal "Trapped an unknown error" $?' ERR + +if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + fatal "Run setup.sh from the root directory of the dotfiles repository." 2 +fi +git submodule update --init --recursive + # Use alias for installing packages so we don't maintain several dependency lists. +if [[ ! -f .bash_aliases ]]; then + fatal "Failed to locate .bash_aliases in path: $(pwd)" 3 +fi . .bash_aliases + +if [[ -z ${DOT_PACKAGES:-} ]]; then + fatal "DOT_PACKAGES variable not found after sourcing $(pwd)/.bash_aliases" 4 +fi sudo apt update -y && sudo apt install -y $DOT_PACKAGES go install github.com/arl/gitmux@latest