From 9a1279899e52ee645026216d8e5f3ded59094871 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Fri, 20 Jan 2017 09:55:13 +0100 Subject: [PATCH 1/3] GHI-#9 Remove overhead functions --- snowblocks/bash/bootstrap | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/snowblocks/bash/bootstrap b/snowblocks/bash/bootstrap index d89ea99..2c750a3 100755 --- a/snowblocks/bash/bootstrap +++ b/snowblocks/bash/bootstrap @@ -12,16 +12,7 @@ # StackOverflow # (http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212) - -__snowblock_bash::get_bootstrap_link_target() { - printf "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" -} - -__snowblock_bash::get_bootstrap_link_source() { - printf "$(readlink $(__snowblock_bash::get_bootstrap_link_target))" -} - -__snowblock_bash::get_base_dir() { +__snowblock_bash::get_module_realpath() { if hash realpath 2>/dev/null; then printf "$(dirname $(realpath "${BASH_SOURCE[0]}"))" else From 51a34c63ee9a7b9c5bdb2c5efd0a9b23c395741b Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Fri, 20 Jan 2017 09:56:19 +0100 Subject: [PATCH 2/3] GHI-#9 Rewrite boostrap base dir- and module name functions --- snowblocks/bash/bootstrap | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/snowblocks/bash/bootstrap b/snowblocks/bash/bootstrap index 2c750a3..835e9eb 100755 --- a/snowblocks/bash/bootstrap +++ b/snowblocks/bash/bootstrap @@ -14,14 +14,18 @@ __snowblock_bash::get_module_realpath() { if hash realpath 2>/dev/null; then - printf "$(dirname $(realpath "${BASH_SOURCE[0]}"))" + printf "$(realpath "${BASH_SOURCE[0]}")" else - printf "$(dirname $(__snowblock_bash::get_bootstrap_link_source))" + printf "$(readlink "${BASH_SOURCE[0]}")" fi } -__snowblock_bash::get_module_basename() { - printf "$($SNOWBLOCK_BASH_BASE_DIR/$(basename "${BASH_SOURCE[0]}"))" +__snowblock_bash::get_module_name() { + printf "$(basename $(__snowblock_bash::get_module_realpath))" +} + +__snowblock_bash::get_base_dir() { + printf "$(dirname $(__snowblock_bash::get_module_realpath))" } __snowblock_bash::log_error() { @@ -58,7 +62,7 @@ __snowblock_bash::setup_history() { } __snowblock_bash::load_core_modules() { - local __self_name="$(basename $(readlink "${BASH_SOURCE[0]}"))" + local __self_name="$(__snowblock_bash::get_module_name)" if [ "$#" -eq 0 ]; then __snowblock_bash::log_debug "[$__self_name] Missing parameter while calling function $FUNCNAME" @@ -84,7 +88,7 @@ __snowblock_bash::load_core_modules() { } __snowblock_bash::load_third_party_scripts() { - local __self_name="$(basename $(readlink "${BASH_SOURCE[0]}"))" + local __self_name="$(__snowblock_bash::get_module_name)" if [ "$#" -eq 0 ]; then __snowblock_bash::log_debug "[$__self_name] Missing parameter while calling function $FUNCNAME" @@ -122,16 +126,15 @@ export SNOWBLOCK_BASH_BINARIES=$SNOWBLOCK_BASH_BASE_DIR/bin __snowblock_bash::load_core_modules loader/env loader/pkg __snowblock_bash::load_core_modules aliases functions prompt shelloptions -# +--------------------+ -# +Third-Party Scripts + -# +--------------------+ +# +---------------------+ +# + Third-Party Scripts + +# +---------------------+ # Git prompt bash support. __snowblock_bash::load_third_party_scripts /usr/share/git/completion/git-prompt.sh - # Programmable bash completion features. __snowblock_bash::load_third_party_scripts /usr/share/bash-completion/bash_completion __snowblock_bash::setup_history __snowblock_bash::register_binaries -__snowblock_bash::log_debug "[$(basename $(__snowblock_bash::get_bootstrap_link_source))] bootstrap completed" +__snowblock_bash::log_debug "[$(__snowblock_bash::get_module_name)] bootstrap completed" From b20a3cb62cccdb5150f70ff27d38bccaa84a5274 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Fri, 20 Jan 2017 09:57:11 +0100 Subject: [PATCH 3/3] GHI-#9 Implement realpath- and name functions for each loader module --- snowblocks/bash/core/loader/env | 14 +++++++++++++- snowblocks/bash/core/loader/pkg | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/snowblocks/bash/core/loader/env b/snowblocks/bash/core/loader/env index 3a84426..b86d8c2 100644 --- a/snowblocks/bash/core/loader/env +++ b/snowblocks/bash/core/loader/env @@ -7,8 +7,20 @@ # email development@arcticicestudio.com + # copyright Copyright (C) 2017 + # ++++++++++++++++++++++++++++++++++++++++++++++++++++++ +__snowblock_bash::core::loader::env::get_module_realpath() { + if hash realpath 2>/dev/null; then + printf "$(realpath "${BASH_SOURCE[0]}")" + else + printf "$(readlink "${BASH_SOURCE[0]}")" + fi +} + +__snowblock_bash::core::loader::env::get_module_name() { + printf "$(basename $(__snowblock_bash::core::loader::env::get_module_realpath))" +} + __snowblock_bash::core::loader::env::load() { - local __self_name="$(basename $(basename "${BASH_SOURCE[0]}"))" + local __self_name="$(__snowblock_bash::core::loader::env::get_module_name)" local envs=$(find -L "$SNOWBLOCK_BASH_BASE_DIR/config/env" -maxdepth 1 -not -name "*.local" -type f) local env diff --git a/snowblocks/bash/core/loader/pkg b/snowblocks/bash/core/loader/pkg index be65fea..1a8b9b7 100644 --- a/snowblocks/bash/core/loader/pkg +++ b/snowblocks/bash/core/loader/pkg @@ -7,8 +7,20 @@ # email development@arcticicestudio.com + # copyright Copyright (C) 2017 + # ++++++++++++++++++++++++++++++++++++++++++++++++++++++ +__snowblock_bash::core::loader::pkg::get_module_realpath() { + if hash realpath 2>/dev/null; then + printf "$(realpath "${BASH_SOURCE[0]}")" + else + printf "$(readlink "${BASH_SOURCE[0]}")" + fi +} + +__snowblock_bash::core::loader::pkg::get_module_name() { + printf "$(basename $(__snowblock_bash::core::loader::pkg::get_module_realpath))" +} + __snowblock_bash::core::loader::pkg::load() { - local __self_name="$(basename $(basename "${BASH_SOURCE[0]}"))" + local __self_name="$(__snowblock_bash::core::loader::pkg::get_module_name)" local pkgs=$(find -L "$SNOWBLOCK_BASH_BASE_DIR/config/pkg" -maxdepth 1 -not -name "*.local" -type f) local pkg