# HG changeset patch # User Meredith Howard # Date 1641759785 18000 # Node ID 28111ba4e573455b0a8a49a1cc7308247567c921 # Parent 0db164e368c5e04862b958db69c92bf0fb1aaa19 move to util lib diff --git a/.lib/sh/util.sh b/.lib/sh/util.sh 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 +} diff --git a/bin/homedir-setup b/bin/homedir-setup --- 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"