From ac25270e13b669ef153889855da2eb321af58fa6 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 10 Jun 2024 23:07:11 -0500 Subject: Change spacing --- dots.sh | 68 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/dots.sh b/dots.sh index 5036e30..e2439f0 100755 --- a/dots.sh +++ b/dots.sh @@ -6,25 +6,25 @@ FORCE=false DIR="$(dirname "$(realpath "$0")")" main() { - action=homify - while getopts hqnfdx OPT - do - case "$OPT" in - (h) usage; exit 0 ;; - (q) QUIET=true ;; - (n) NORUN=true ;; - (f) FORCE=true ;; - (d) action=dotify ;; - (x) set -x ;; - (*) usage; exit 1 ;; - esac - done - shift $((OPTIND - 1)) - "$action" "$@" + action=homify + while getopts hqnfdx OPT + do + case "$OPT" in + (h) usage; exit 0 ;; + (q) QUIET=true ;; + (n) NORUN=true ;; + (f) FORCE=true ;; + (d) action=dotify ;; + (x) set -x ;; + (*) usage; exit 1 ;; + esac + done + shift $((OPTIND - 1)) + "$action" "$@" } usage() { - cat<&2 "* $@"; } run() { log "$@"; $NORUN || "$@"; } mklink() { # mklink SOURCE DEST - # make hardlinks to DEST from SOURCE -- making directories - $NORUN || test -d "$(dirname "$2")" || run mkdir -p "$(dirname "$2")" - if ! test -f "$2" - then run ln "$1" "$2" - elif test -f "$2" && "$FORCE" - then run ln -f "$1" "$2" - else log "$2 exists: skipping" - fi + # make hardlinks to DEST from SOURCE -- making directories + $NORUN || test -d "$(dirname "$2")" || run mkdir -p "$(dirname "$2")" + if ! test -f "$2" + then run ln "$1" "$2" + elif test -f "$2" && "$FORCE" + then run ln -f "$1" "$2" + else log "$2 exists: skipping" + fi } getfiles() { - d="$1"; shift - find "$d" -type f -a -not -name "$(basename "$0")" "$@" + d="$1"; shift + find "$d" -type f -a -not -name "$(basename "$0")" "$@" } homify() { - getfiles "$DIR" "$@" | - while read -r dot - do mklink "$dot" "$HOME/.${dot#$DIR/}" - done + getfiles "$DIR" "$@" | + while read -r dot + do mklink "$dot" "$HOME/.${dot#$DIR/}" + done } dotify() { - getfiles "$@" | - while read -r file - do mklink "$file" "$DIR/${file#.}" - done + getfiles "$@" | + while read -r file + do mklink "$file" "$DIR/${file#.}" + done } main "$@" -- cgit 1.4.1-21-gabe81