From 7ec6dc98c959dc61f7d8ab4617fd907f895afdc7 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 15 Feb 2020 15:25:20 +0100 Subject: [PATCH] Fix utility sourcing Utilities should always be sourced, even in the case that the processor is not designated for any of the templates provided. --- example_template | 11 +++++------ theme_qutebrowser | 11 +++++------ theme_rofi | 11 +++++------ theme_shell | 11 +++++------ theme_vim | 11 +++++------ theme_xresources | 11 +++++------ 6 files changed, 30 insertions(+), 36 deletions(-) diff --git a/example_template b/example_template index a63409c..57975d5 100644 --- a/example_template +++ b/example_template @@ -58,17 +58,16 @@ include() { dbg_msg $app "Sucessfully included theme" } +# Safe sourcing: https://stackoverflow.com/a/12694189 +DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi +# shellcheck source=utilities.sh +. "$DIR/utilities.sh" ## Dependency Checker # # Makes sure the processor is called for the correct # base16 package, or refuses to run if it is not. if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then - # Safe sourcing: https://stackoverflow.com/a/12694189 - DIR="${BASH_SOURCE%/*}" - if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - # shellcheck source=utilities.sh - . "$DIR/utilities.sh" - main else dbg_msg $app "error" "Processor does not work for package $package" diff --git a/theme_qutebrowser b/theme_qutebrowser index 7109b1f..de10f63 100755 --- a/theme_qutebrowser +++ b/theme_qutebrowser @@ -77,17 +77,16 @@ include() { fi } +# Safe sourcing: https://stackoverflow.com/a/12694189 +DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi +# shellcheck source=utilities.sh +. "$DIR/utilities.sh" ## Dependency Checker # # Makes sure the processor is called for the correct # base16 package, or refuses to run if it is not. if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then - # Safe sourcing: https://stackoverflow.com/a/12694189 - DIR="${BASH_SOURCE%/*}" - if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - # shellcheck source=utilities.sh - . "$DIR/utilities.sh" - main else dbg_msg $app "error" "Processor does not work for package $package" diff --git a/theme_rofi b/theme_rofi index 9ded370..f549eaf 100755 --- a/theme_rofi +++ b/theme_rofi @@ -73,17 +73,16 @@ include() { dbg_msg $app "Sucessfully included theme" } +# Safe sourcing: https://stackoverflow.com/a/12694189 +DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi +# shellcheck source=utilities.sh +. "$DIR/utilities.sh" ## Dependency Checker # # Makes sure the processor is called for the correct # base16 package, or refuses to run if it is not. if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then - # Safe sourcing: https://stackoverflow.com/a/12694189 - DIR="${BASH_SOURCE%/*}" - if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - # shellcheck source=utilities.sh - . "$DIR/utilities.sh" - main else dbg_msg $app "error" "Processor does not work for package $package" diff --git a/theme_shell b/theme_shell index b52c688..ee3a950 100755 --- a/theme_shell +++ b/theme_shell @@ -66,17 +66,16 @@ theme() { # dbg_msg $app "Sucessfully included theme" #} +# Safe sourcing: https://stackoverflow.com/a/12694189 +DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi +# shellcheck source=utilities.sh +. "$DIR/utilities.sh" ## Dependency Checker # # Makes sure the processor is called for the correct # base16 package, or refuses to run if it is not. if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then - # Safe sourcing: https://stackoverflow.com/a/12694189 - DIR="${BASH_SOURCE%/*}" - if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - # shellcheck source=utilities.sh - . "$DIR/utilities.sh" - main else dbg_msg $app "error" "Processor does not work for package $package" diff --git a/theme_vim b/theme_vim index ed43e6f..7818a37 100755 --- a/theme_vim +++ b/theme_vim @@ -98,17 +98,16 @@ include() { fi } +# Safe sourcing: https://stackoverflow.com/a/12694189 +DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi +# shellcheck source=utilities.sh +. "$DIR/utilities.sh" ## Dependency Checker # # Makes sure the processor is called for the correct # base16 package, or refuses to run if it is not. if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then - # Safe sourcing: https://stackoverflow.com/a/12694189 - DIR="${BASH_SOURCE%/*}" - if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - # shellcheck source=utilities.sh - . "$DIR/utilities.sh" - main else dbg_msg $app "error" "Processor does not work for package $package" diff --git a/theme_xresources b/theme_xresources index 347c41e..dd2df70 100755 --- a/theme_xresources +++ b/theme_xresources @@ -86,17 +86,16 @@ include() { fi } +# Safe sourcing: https://stackoverflow.com/a/12694189 +DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi +# shellcheck source=utilities.sh +. "$DIR/utilities.sh" ## Dependency Checker # # Makes sure the processor is called for the correct # base16 package, or refuses to run if it is not. if printf '%s\n' "${dependency[@]}" | grep -q -P "^$package$"; then - # Safe sourcing: https://stackoverflow.com/a/12694189 - DIR="${BASH_SOURCE%/*}" - if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi - # shellcheck source=utilities.sh - . "$DIR/utilities.sh" - main else dbg_msg $app "error" "Processor does not work for package $package"