From c76b5f2776b7874d5883d1e976e14235450dbb9c Mon Sep 17 00:00:00 2001 From: oogee Date: Tue, 21 May 2024 18:28:52 +0300 Subject: [PATCH] Use shell parameter expansion to make getting source path work in non-bash shells (#24598) Currently `BASH_SOURCE[0]` was used, which is only available on bash. I changed it to `${BASH_SOURCE:-$0}` which is supported by at least bash, zsh and dash, as explained by [https://stackoverflow.com/a/68359914/9028340](https://stackoverflow.com/a/68359914/9028340) It uses shell parameter expansion https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion Addresses #17392 --- .github/dockerfiles/docker_tag | 2 +- samples/cpp/build_samples.sh | 4 ++-- scripts/install_dependencies/install_openvino_dependencies.sh | 2 +- scripts/setupvars/setupvars.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tag index 7034e77052f..094e08dade5 100644 --- a/.github/dockerfiles/docker_tag +++ b/.github/dockerfiles/docker_tag @@ -1 +1 @@ -pr-24395 \ No newline at end of file +pr-24598 diff --git a/samples/cpp/build_samples.sh b/samples/cpp/build_samples.sh index fc171a27227..d20e5b7403e 100755 --- a/samples/cpp/build_samples.sh +++ b/samples/cpp/build_samples.sh @@ -17,7 +17,7 @@ usage() { exit 1 } -samples_type="$(basename "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")" +samples_type="$(basename "$(dirname "$(realpath "${BASH_SOURCE:-$0}")")")" samples_build_dir="$HOME/openvino_${samples_type}_samples_build" sample_install_dir="" @@ -55,7 +55,7 @@ error() { } trap 'error ${LINENO}' ERR -SAMPLES_SOURCE_DIR="$( cd "$( dirname "$(realpath "${BASH_SOURCE[0]}")" )" && pwd )" +SAMPLES_SOURCE_DIR="$( cd "$( dirname "$(realpath "${BASH_SOURCE:-$0}")" )" && pwd )" printf "\nSetting environment variables for building samples...\n" if [ -z "$INTEL_OPENVINO_DIR" ]; then diff --git a/scripts/install_dependencies/install_openvino_dependencies.sh b/scripts/install_dependencies/install_openvino_dependencies.sh index b2b64ec01c3..fd3e2a5c887 100755 --- a/scripts/install_dependencies/install_openvino_dependencies.sh +++ b/scripts/install_dependencies/install_openvino_dependencies.sh @@ -66,7 +66,7 @@ if [ -n "$selftest" ] ; then echo "||" echo "|| Test $image / '$opt'" echo "||" - SCRIPT_DIR="$( cd "$( dirname "$(realpath "${BASH_SOURCE[0]}")" )" >/dev/null 2>&1 && pwd )" + SCRIPT_DIR="$( cd "$( dirname "$(realpath "${BASH_SOURCE:-$0}")" )" >/dev/null 2>&1 && pwd )" docker run -it --rm \ --volume "${SCRIPT_DIR}":/scripts:ro,Z \ --volume yum-cache:/var/cache/yum \ diff --git a/scripts/setupvars/setupvars.sh b/scripts/setupvars/setupvars.sh index e4801265735..e2dc114a5a2 100755 --- a/scripts/setupvars/setupvars.sh +++ b/scripts/setupvars/setupvars.sh @@ -10,7 +10,7 @@ abs_path () { pwd -P } -SCRIPT_DIR="$(abs_path "${BASH_SOURCE[0]}")" >/dev/null 2>&1 +SCRIPT_DIR="$(abs_path "${BASH_SOURCE:-$0}")" >/dev/null 2>&1 INSTALLDIR="${SCRIPT_DIR}" export INTEL_OPENVINO_DIR="$INSTALLDIR"