From a20eacfd320c6f3144e1e4e598248cdd804d48f4 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Thu, 9 Mar 2023 13:47:44 +0100 Subject: Use more local vars --- playbook.bash | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/playbook.bash b/playbook.bash index 1f47ebc..69c0ef0 100644 --- a/playbook.bash +++ b/playbook.bash @@ -1,29 +1,35 @@ #!/usr/bin/env bash BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.branch]="" -BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.generator]="" +BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.generator]="required" BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.path]="" BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.remote]="" BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.repository]="required" playbook_add() { local path + local remote + local repo path="$(config "$BASHTARD_PLAYBOOK.path" "/var/www/$BASHTARD_PLAYBOOK")" + remote="$(config "$BASHTARD_PLAYBOOK.remote" "origin")" + repo="$(config "$BASHTARD_PLAYBOOK.repository")" mkdir -p -- "$path" git -C "$path" init - git -C "$path" remote add "$(config "$BASHTARD_PLAYBOOK.remote" "origin")" "$(config "$BASHTARD_PLAYBOOK.repository")" + git -C "$path" remote add "$remote" "$repo" playbook_sync } playbook_sync() { local branch + local generator local path local remote branch="$(config "$BASHTARD_PLAYBOOK.branch" "master")" + generator="$(config "$BASHTARD_PLAYBOOK.generator")" path="$(config "$BASHTARD_PLAYBOOK.path" "/var/www/$BASHTARD_PLAYBOOK")" remote="$(config "$BASHTARD_PLAYBOOK.remote" "origin")" @@ -32,13 +38,13 @@ playbook_sync() { chgdir "$path" - case "$(config "$BASHTARD_PLAYBOOK.generator")" in + case "$generator" in hugo) hugo -D # This will generate all the draft content hugo # And this will generate the actual live blog, but won't remove the draft content ;; *) - crit "$BASHTARD_PLAYBOOK/sync" "Unsupported generator '$(config "$BASHTARD_PLAYBOOK.generator")'" + crit "$BASHTARD_PLAYBOOK/sync" "Unsupported generator '$generator'" esac } -- cgit v1.1