Skip to content

Commit

Permalink
refactor: script_path
Browse files Browse the repository at this point in the history
  • Loading branch information
codekow committed Oct 8, 2024
1 parent 218f604 commit c307549
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ check_git_root(){
fi
}

get_script_path(){
check_script_path(){
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
}

check_shell
check_git_root
get_script_path
check_script_path

################# standard init #################

Expand Down
9 changes: 3 additions & 6 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash
# shellcheck disable=SC1091,SC2034

RED='\033[1;31m'
BLUE='\033[1;36m'
PURPLE='\033[1;35m'
ORANGE='\033[0;33m'
NC='\033[0m' # No Color

check_shell(){
[ -n "$BASH_VERSION" ] && return
[ -n "${BASH_VERSION}" ] && return
echo -e "${ORANGE}WARNING: These scripts are ONLY tested in a bash shell${NC}"
sleep "${SLEEP_SECONDS:-8}"
}
Expand All @@ -27,7 +24,7 @@ check_git_root(){
fi
}

get_script_path(){
check_script_path(){
[ -n "${SCRIPT_DIR}" ] && return

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Expand Down Expand Up @@ -70,7 +67,7 @@ is_sourced(){

check_shell
check_git_root
get_script_path
check_script_path
source_library
setup_bin_path

Expand Down
4 changes: 2 additions & 2 deletions scripts/reverse_tunnel/reverse_tunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ kludge_install_user(){
}

kludge_install_app(){
SCRIPT_DIR=$(get_script_path)
SCRIPT_DIR=$(check_script_path)
[ "${SCRIPT_DIR}" == "/usr/local/bin" ] && return

# install script and env into ${APP_PATH}
Expand Down Expand Up @@ -142,7 +142,7 @@ var_unset(){
echo "${1} env var is NOT set"
}

get_script_path(){
check_script_path(){
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
echo "${SCRIPT_DIR}"
}
Expand Down

0 comments on commit c307549

Please sign in to comment.