#!/usr/bin/env bash # NOTE: this is way simpler echo $(realpath "${BASH_SOURCE}") # NOTE: this is useless if [[ "${0}" == "${BASH_SOURCE}" ]]; then root_dir="$(dirname "${0}")" root_dir="$(realpath "${root_dir}")" else root_dir="$(dirname "${0}")/$(dirname "${BASH_SOURCE}")" root_dir="$(realpath "${root_dir}")" fi tput smso echo ${root_dir} tput rmso echo "blargh"