From d01591a0d48ebb7530ad38e3e73f5df7d0b92b91 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 18 Jun 2020 13:34:41 +1000 Subject: [PATCH] Wrap the loose commands at the end of dots in a function too, to help guarantee harmless crashing if the script's download is interrupted --- local/bin/dots | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/local/bin/dots b/local/bin/dots index d6133e6..d62b977 100755 --- a/local/bin/dots +++ b/local/bin/dots @@ -128,22 +128,26 @@ done } -: ${DOTFILES:=~/dotfiles} ${STOW:=stow} ${GITHUB_USER:=00dani} +'main'() { + : ${DOTFILES:=~/dotfiles} ${STOW:=stow} ${GITHUB_USER:=00dani} -comm=$1 -if (( $# == 0 )); then - if [[ -d $DOTFILES ]]; then - comm=status - else - comm=bootstrap + comm=$1 + if (( $# == 0 )); then + if [[ -d $DOTFILES ]]; then + comm=status + else + comm=bootstrap + fi fi -fi -case $comm in - bootstrap) bootstrap ;; - clone) clone ${argv[2,-1]} ;; - fetch) fetch ${argv[2,-1]} ;; - link) link ${argv[2,-1]} ;; - pull) pull ${argv[2,-1]} ;; - st|status) status ${argv[2,-1]} ;; -esac + case $comm in + bootstrap) bootstrap ;; + clone) clone ${argv[2,-1]} ;; + fetch) fetch ${argv[2,-1]} ;; + link) link ${argv[2,-1]} ;; + pull) pull ${argv[2,-1]} ;; + st|status) status ${argv[2,-1]} ;; + esac +} + +'main'