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
This commit is contained in:
parent
76d3410a7c
commit
c76b5f2776
|
|
@ -1 +1 @@
|
|||
pr-24395
|
||||
pr-24598
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue