From 23aea386b9deab7551f7458221cecbf34ae5b93d Mon Sep 17 00:00:00 2001 From: Oliver Ford Date: Fri, 4 Nov 2022 22:47:37 +0000 Subject: [PATCH] Refactor readlink_f to common helpers --- bin/terraform | 13 ------------- bin/tfenv | 13 ------------- lib/helpers.sh | 28 +++++++++++++++------------- lib/tfenv-exec.sh | 15 --------------- libexec/tfenv---version | 14 -------------- libexec/tfenv-exec | 14 -------------- libexec/tfenv-install | 14 -------------- libexec/tfenv-list | 14 -------------- libexec/tfenv-list-remote | 14 -------------- libexec/tfenv-min-required | 14 -------------- libexec/tfenv-pin | 14 -------------- libexec/tfenv-resolve-version | 14 -------------- libexec/tfenv-uninstall | 14 -------------- libexec/tfenv-use | 14 -------------- libexec/tfenv-version-file | 14 -------------- libexec/tfenv-version-name | 14 -------------- test/run.sh | 14 -------------- test/test_install_and_use.sh | 14 -------------- test/test_list.sh | 14 -------------- test/test_symlink.sh | 14 -------------- test/test_uninstall.sh | 14 -------------- test/test_use_latestallowed.sh | 14 -------------- test/test_use_minrequired.sh | 14 -------------- 23 files changed, 15 insertions(+), 320 deletions(-) diff --git a/bin/terraform b/bin/terraform index cec01d26..c613df93 100755 --- a/bin/terraform +++ b/bin/terraform @@ -11,19 +11,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "${target_file%/*}" || early_death "Failed to 'cd \$(${target_file%/*})' while trying to determine TFENV_ROOT"; - file_name="${target_file##*/}" || early_death "Failed to '\"${target_file##*/}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; TFENV_SHIM=$(readlink_f "${0}") TFENV_ROOT="${TFENV_SHIM%/*/*}"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to determine TFENV_ROOT"; diff --git a/bin/tfenv b/bin/tfenv index 28c24a18..d2fe3139 100755 --- a/bin/tfenv +++ b/bin/tfenv @@ -11,19 +11,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "${target_file%/*}" || early_death "Failed to 'cd \$(${target_file%/*})' while trying to determine TFENV_ROOT"; - file_name="${target_file##*/}" || early_death "Failed to '\"${target_file##*/}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; TFENV_SHIM=$(readlink_f "${0}") TFENV_ROOT="${TFENV_SHIM%/*/*}"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to determine TFENV_ROOT"; diff --git a/lib/helpers.sh b/lib/helpers.sh index 535232dc..695dd7b0 100755 --- a/lib/helpers.sh +++ b/lib/helpers.sh @@ -2,20 +2,22 @@ set -uo pipefail; +# http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac +readlink_f() { + local target_file="${1}"; + local file_name; + + while [ "${target_file}" != "" ]; do + cd "${target_file%/*}" || early_death "Failed to 'cd \$(${target_file%/*})'"; + file_name="${target_file##*/}" || early_death "Failed to '\"${target_file##*/}\"'"; + target_file="$(readlink "${file_name}")"; + done; + + echo "$(pwd -P)/${file_name}"; +}; +export -f readlink_f; + if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "${target_file%/*}" || early_death "Failed to 'cd \$(${target_file%/*})' while trying to determine TFENV_ROOT"; - file_name="${target_file##*/}" || early_death "Failed to '\"${target_file##*/}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; TFENV_SHIM=$(readlink_f "${0}") TFENV_ROOT="${TFENV_SHIM%/*/*}"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to determine TFENV_ROOT"; diff --git a/lib/tfenv-exec.sh b/lib/tfenv-exec.sh index 66af4cd9..d0bd2472 100644 --- a/lib/tfenv-exec.sh +++ b/lib/tfenv-exec.sh @@ -5,21 +5,6 @@ set -uo pipefail; function realpath-relative-to() { # A basic implementation of GNU `realpath --relative-to=$1 $2` # that can also be used on macOS. - - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname "$target_file")" || early_death "Failed to 'cd \$(${target_file%/*})'"; - file_name="${target_file##*/}" || early_death "Failed to '\"${target_file##*/}\"'"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - local relative_to="$(readlink_f "${1}")"; local path="$(readlink_f "${2}")"; diff --git a/libexec/tfenv---version b/libexec/tfenv---version index 52198f83..57533acc 100755 --- a/libexec/tfenv---version +++ b/libexec/tfenv---version @@ -21,20 +21,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-exec b/libexec/tfenv-exec index 9d3be482..93193303 100755 --- a/libexec/tfenv-exec +++ b/libexec/tfenv-exec @@ -25,20 +25,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-install b/libexec/tfenv-install index d13b3847..99c916d4 100755 --- a/libexec/tfenv-install +++ b/libexec/tfenv-install @@ -11,20 +11,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-list b/libexec/tfenv-list index 3e50c51c..8685cab1 100755 --- a/libexec/tfenv-list +++ b/libexec/tfenv-list @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-list-remote b/libexec/tfenv-list-remote index 0e8a6fcf..b847ad9a 100755 --- a/libexec/tfenv-list-remote +++ b/libexec/tfenv-list-remote @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname "${target_file}")" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-min-required b/libexec/tfenv-min-required index 80d91b1b..bccaf778 100755 --- a/libexec/tfenv-min-required +++ b/libexec/tfenv-min-required @@ -14,20 +14,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-pin b/libexec/tfenv-pin index 1c7077cf..8f548bc5 100755 --- a/libexec/tfenv-pin +++ b/libexec/tfenv-pin @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-resolve-version b/libexec/tfenv-resolve-version index d0b66bce..b9b45ce4 100755 --- a/libexec/tfenv-resolve-version +++ b/libexec/tfenv-resolve-version @@ -14,20 +14,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-uninstall b/libexec/tfenv-uninstall index 83289c85..86acc597 100755 --- a/libexec/tfenv-uninstall +++ b/libexec/tfenv-uninstall @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-use b/libexec/tfenv-use index 0c411cc6..5094de23 100755 --- a/libexec/tfenv-use +++ b/libexec/tfenv-use @@ -11,20 +11,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-version-file b/libexec/tfenv-version-file index 153a29ea..c3204318 100755 --- a/libexec/tfenv-version-file +++ b/libexec/tfenv-version-file @@ -14,20 +14,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/libexec/tfenv-version-name b/libexec/tfenv-version-name index db4ee4c8..35ec3133 100755 --- a/libexec/tfenv-version-name +++ b/libexec/tfenv-version-name @@ -13,20 +13,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n "${TFENV_ROOT}" ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/test/run.sh b/test/run.sh index 0e1d3629..010b437b 100755 --- a/test/run.sh +++ b/test/run.sh @@ -11,20 +11,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/test/test_install_and_use.sh b/test/test_install_and_use.sh index fd2b6f01..bdc9ac89 100755 --- a/test/test_install_and_use.sh +++ b/test/test_install_and_use.sh @@ -11,20 +11,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/test/test_list.sh b/test/test_list.sh index bcb8d57d..93879eaa 100755 --- a/test/test_list.sh +++ b/test/test_list.sh @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/test/test_symlink.sh b/test/test_symlink.sh index 3c99bfd2..21b674ed 100755 --- a/test/test_symlink.sh +++ b/test/test_symlink.sh @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/test/test_uninstall.sh b/test/test_uninstall.sh index 70fe803c..98a9603f 100755 --- a/test/test_uninstall.sh +++ b/test/test_uninstall.sh @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/test/test_use_latestallowed.sh b/test/test_use_latestallowed.sh index 10af0d57..1032bf5e 100755 --- a/test/test_use_latestallowed.sh +++ b/test/test_use_latestallowed.sh @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else diff --git a/test/test_use_minrequired.sh b/test/test_use_minrequired.sh index c39ea99d..5bad29c3 100755 --- a/test/test_use_minrequired.sh +++ b/test/test_use_minrequired.sh @@ -12,20 +12,6 @@ function early_death() { }; if [ -z "${TFENV_ROOT:-""}" ]; then - # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac - readlink_f() { - local target_file="${1}"; - local file_name; - - while [ "${target_file}" != "" ]; do - cd "$(dirname ${target_file})" || early_death "Failed to 'cd \$(dirname ${target_file})' while trying to determine TFENV_ROOT"; - file_name="$(basename "${target_file}")" || early_death "Failed to 'basename \"${target_file}\"' while trying to determine TFENV_ROOT"; - target_file="$(readlink "${file_name}")"; - done; - - echo "$(pwd -P)/${file_name}"; - }; - TFENV_ROOT="$(cd "$(dirname "$(readlink_f "${0}")")/.." && pwd)"; [ -n ${TFENV_ROOT} ] || early_death "Failed to 'cd \"\$(dirname \"\$(readlink_f \"${0}\")\")/..\" && pwd' while trying to determine TFENV_ROOT"; else