From ce3b7dfb1ee60b9a20f63891e6ae6b9db1cfc5e9 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 19 Aug 2019 16:59:36 -0500 Subject: [PATCH] Use readlink -f if realpath isn't available --- scripts/tasks.bash | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/tasks.bash b/scripts/tasks.bash index 29af27a7..c4d2144d 100755 --- a/scripts/tasks.bash +++ b/scripts/tasks.bash @@ -190,12 +190,21 @@ function binary-task() { log "Binary: ${buildPath}/${binaryName}" } +function absolute-path() { + local relative="${1}"; shift + if command -v realpath &> /dev/null ; then + realpath "${relative}" + else + readlink -f "${relative}" + fi +} + # Check if it looks like we are inside VS Code. function in-vscode () { local dir="${1}" ; shift local maybeVsCode local dirName - maybeVsCode="$(realpath "${dir}/../../..")" + maybeVsCode="$(absolute-path "${dir}/../../..")" dirName="$(basename "${maybeVsCode}")" if [[ "${dirName}" != "vscode" ]] ; then return 1 @@ -213,7 +222,7 @@ function main() { local relativeRootPath local rootPath relativeRootPath="$(dirname "${0}")/.." - rootPath="$(realpath "${relativeRootPath}")" + rootPath="$(absolute-path "${relativeRootPath}")" local task="${1}" ; shift if [[ "${task}" == "ensure-in-vscode" ]] ; then -- GitLab