move to util lib

Sun, 09 Jan 2022 15:23:05 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 09 Jan 2022 15:23:05 -0500
changeset 969
28111ba4e573
parent 968
0db164e368c5
child 970
498189926551

move to util lib

.lib/sh/util.sh file | annotate | diff | comparison | revisions
bin/homedir-setup file | annotate | diff | comparison | revisions
new file mode 100644
--- /dev/null
+++ b/.lib/sh/util.sh
@@ -0,0 +1,11 @@
+warn() { echo "$*" >&2; }
+die() { warn "$*"; exit 1; }
+
+clone_or_pull() {
+  if ! [ -d $2 ]; then
+    git clone --single-branch --depth 1 "$1" $2
+  else
+    echo "$2:"
+    git -C "$2" pull
+  fi
+}
--- a/bin/homedir-setup
+++ b/bin/homedir-setup
@@ -1,17 +1,7 @@
 #!/bin/bash
 set -euo pipefail
 
-warn() { echo "$*" >&2; }
-die() { warn "$*"; exit 1; }
-
-clone_or_pull() {
-  if ! [ -d $2 ]; then
-    git clone --single-branch --depth 1 "$1" $2
-  else
-    echo "$2:"
-    git -C "$2" pull
-  fi
-}
+source .lib/sh/util.sh
 
 [ -f .zshrc ] ||
   die "Refusing to run without a .zshrc nearby"

mercurial