From d8652a8ebd230ef72322e91f7952891d048f4448 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 4 Jul 2024 20:17:30 -0700 Subject: [PATCH] add fallback when `sh/obtain` is missing --- update | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/update b/update index d1b5730..b1c348a 100755 --- a/update +++ b/update @@ -28,11 +28,21 @@ die() { backup="backup-$(date -u +%s)" || die 'failed to determine date' -# load libraries. -# TODO: write a simple fallback when the library is missing! +if ! [ -e sh/obtain ]; then + url=https://eaguru.guru/git/notwa/rc/raw/branch/master/sh/obtain + if curl 2>&-; [ $? = 2 ]; then acquire() { curl -fsS -m45 -o- "$*" ;} + elif wget 2>&-; [ $? = 1 ]; then acquire() { wget -qt1 -T45 -O- "$*" ;} + else die '"sh/obtain" missing, curl and wget missing as well' + fi + mkdir -p sh || die 'failed to create "sh" directory' + acquire "$url" > sh/obtain && chmod +x sh/obtain || + die 'failed to acquire "sh/obtain"' +fi + dummy() { :; } preload=dummy -. sh/obtain +(. sh/obtain) || die 'failed to import "sh/obtain"' +. sh/obtain || exit __obtain_prep