clean up

Sun, 09 Jan 2022 15:14:11 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 09 Jan 2022 15:14:11 -0500
changeset 967
9314317ed18f
parent 966
e1132c1cce12
child 968
0db164e368c5

clean up

bin/homedir-setup file | annotate | diff | comparison | revisions
--- a/bin/homedir-setup
+++ b/bin/homedir-setup
@@ -1,15 +1,8 @@
 #!/bin/bash
 set -euo pipefail
 
-if [ ! -f .zshrc ]; then
-  echo "Refusing to run without a .zshrc nearby" >&2
-  exit 1
-fi
-
-if ! git --version >/dev/null; then
-  echo "Please install git!" >&2
-  exit 1
-fi
+warn() { echo "$*" >&2; }
+die() { warn "$*"; exit 1; }
 
 clone_or_pull() {
   if ! [ -d $2 ]; then
@@ -20,6 +13,12 @@ clone_or_pull() {
   fi
 }
 
+[ -f .zshrc ] ||
+  die "Refusing to run without a .zshrc nearby"
+
+git --version >/dev/null ||
+  die "Please install git!"
+
 clone_or_pull 'https://github.com/tarjoilija/zgen.git' .zgen
 
 zsh -i -c 'zgen update' || :
@@ -35,7 +34,7 @@ bin/setup-man || :
 # Get rid of older stuff
 for OLD in .plenv .rbenv .ndenv; do
   if [ -e $OLD ]; then
-    echo "Pruning $OLD" >&2
+    warn "Pruning $OLD"
     rm -rf $OLD
   fi
 done

mercurial