From cd0b9c4ec0bb7ae32d2a91ef711ee5b94cd44be0 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 29 Oct 2024 08:45:59 +0000 Subject: [PATCH] Meta: Add cross-platform function for absolutizing paths --- Meta/shell_include.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Meta/shell_include.sh b/Meta/shell_include.sh index 864d8c5d143..855ac95514f 100644 --- a/Meta/shell_include.sh +++ b/Meta/shell_include.sh @@ -83,3 +83,14 @@ get_build_dir() { echo "${BUILD_DIR}" } + +absolutize_path() { + directory="$(eval echo "$(dirname "$1")")" + if [ -d "$directory" ]; then + resolved_directory="$(cd "$directory" && pwd)" + echo "${resolved_directory%/}/$(basename "$1")" + else + echo "No such directory: '$directory'" >&2 + return 1 + fi +}