Skip to content

Commit

Permalink
Merge branch 'improvement/ghi-#9-snowblock-bash-unoptimized-base-dir-…
Browse files Browse the repository at this point in the history
…and-module-name-detection-functions' into develop
  • Loading branch information
arcticicestudio committed Jan 20, 2017
2 parents 08d2720 + b20a3cb commit c3e9a79
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
36 changes: 15 additions & 21 deletions snowblocks/bash/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,20 @@
# 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]}"))"
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() {
Expand Down Expand Up @@ -67,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"
Expand All @@ -93,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"
Expand Down Expand Up @@ -131,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"
14 changes: 13 additions & 1 deletion snowblocks/bash/core/loader/env
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@
# email [email protected] +
# 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

Expand Down
14 changes: 13 additions & 1 deletion snowblocks/bash/core/loader/pkg
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@
# email [email protected] +
# 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

Expand Down

0 comments on commit c3e9a79

Please sign in to comment.