Recycle project_root output

This commit is contained in:
Michael Wolf
2023-09-30 17:17:00 -06:00
parent 08be19fe28
commit fd384a91ea

View File

@@ -16,8 +16,16 @@ function get_os() {
# For a given file, return its corresponding project root. # For a given file, return its corresponding project root.
function project_root() { function project_root() {
set +u
if [[ ! -z "${PROJECT_ROOT}" ]]; then
echo "$PROJECT_ROOT"
return 0
fi
set -u
pushd "$(dirname "$1")" >/dev/null 2>&1 || exit 101 pushd "$(dirname "$1")" >/dev/null 2>&1 || exit 101
out=$(git rev-parse --show-toplevel) out=$(git rev-parse --show-toplevel)
ret="$?" ret="$?"
popd >/dev/null 2>&1 || exit 1 popd >/dev/null 2>&1 || exit 1