From da625b995efb0a39f4f916b7beefe66a0898dc69 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 9 Oct 2020 13:25:53 +0300 Subject: [PATCH] Shellcheck update (#2557) * Fixed SC2236 rules * Fixed SC2086 rule * Small fixes in other scripts --- cmake/shellcheck/shellcheck.cmake | 2 +- cmake/shellcheck/shellcheck_process.cmake | 2 +- inference-engine/samples/build_samples.sh | 2 +- inference-engine/scripts/dependencies.sh | 2 +- inference-engine/scripts/run_code_checks.sh | 60 +++++------ .../scripts/run_tests_myriad_multistick.sh | 4 +- .../tests/test_onnx/model_zoo_preprocess.sh | 102 +++++++++--------- scripts/demo/demo_benchmark_app.sh | 24 ++--- scripts/demo/demo_security_barrier_camera.sh | 22 ++-- .../demo_squeezenet_download_convert_run.sh | 24 ++--- .../install_NCS_udev_rules.sh | 2 + .../install_NEO_OCL_driver.sh | 74 ++++++------- scripts/setupvars/setupvars.sh | 4 +- 13 files changed, 163 insertions(+), 161 deletions(-) diff --git a/cmake/shellcheck/shellcheck.cmake b/cmake/shellcheck/shellcheck.cmake index 8ee725982b9..c2e1186d1b1 100644 --- a/cmake/shellcheck/shellcheck.cmake +++ b/cmake/shellcheck/shellcheck.cmake @@ -39,7 +39,7 @@ function(ie_shellcheck_process) -D IE_SHELL_SCRIPT=${script} -D IE_SHELLCHECK_OUTPUT=${output_file} -P ${IE_SHELLCHECK_SCRIPT} - DEPENDS ${script} + DEPENDS ${script} ${IE_SHELLCHECK_SCRIPT} COMMENT "Check script ${script_name}" VERBATIM) list(APPEND outputs ${output_file}) diff --git a/cmake/shellcheck/shellcheck_process.cmake b/cmake/shellcheck/shellcheck_process.cmake index d483ff67cf7..1dcf121c379 100644 --- a/cmake/shellcheck/shellcheck_process.cmake +++ b/cmake/shellcheck/shellcheck_process.cmake @@ -14,7 +14,7 @@ if(NOT DEFINED IE_SHELLCHECK_OUTPUT) message(FATAL_ERROR "IE_SHELLCHECK_OUTPUT is not defined") endif() -set(rules "SC1091,SC2236,SC2164,SC2086,SC2162,SC1090") +set(rules "SC1091,SC2164,SC2162,SC1090") execute_process(COMMAND ${IE_SHELLCHECK_PROGRAM} --exclude=${rules} ${IE_SHELL_SCRIPT} OUTPUT_VARIABLE error_message RESULT_VARIABLE exit_code diff --git a/inference-engine/samples/build_samples.sh b/inference-engine/samples/build_samples.sh index 2b364a4444a..68697325496 100755 --- a/inference-engine/samples/build_samples.sh +++ b/inference-engine/samples/build_samples.sh @@ -64,7 +64,7 @@ if [ "$OS_PATH" == "x86_64" ]; then fi if [ -e "$build_dir/CMakeCache.txt" ]; then - rm -rf "$build_dir/CMakeCache.txt" + rm -rf "$build_dir/CMakeCache.txt" fi mkdir -p "$build_dir" cd "$build_dir" diff --git a/inference-engine/scripts/dependencies.sh b/inference-engine/scripts/dependencies.sh index 5f15c8358a8..09051b7075a 100755 --- a/inference-engine/scripts/dependencies.sh +++ b/inference-engine/scripts/dependencies.sh @@ -44,7 +44,7 @@ export_library_path() { } export_env_variable() { - export $2="$DL_SDK_TEMP/test_dependencies/$1" + export "$2"="$DL_SDK_TEMP/test_dependencies/$1" } ma2480_path="" diff --git a/inference-engine/scripts/run_code_checks.sh b/inference-engine/scripts/run_code_checks.sh index d3bdb355cce..ef7b64cfd87 100755 --- a/inference-engine/scripts/run_code_checks.sh +++ b/inference-engine/scripts/run_code_checks.sh @@ -4,19 +4,19 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" command -v realpath >/dev/null 2>&1 || { echo >&2 "cpplint require realpath executable but it's not installed. Aborting."; exit 1; } -SOURCE_DIR=$(realpath ${CURRENT_DIR}/..) +SOURCE_DIR=$(realpath "${CURRENT_DIR}/..") REPORT_DIR="${SOURCE_DIR}/report" CPPLINT_REPORT_DIR="${REPORT_DIR}/cpplint" PROJECT_NAME="Inference Engine" function run_cpplint() { echo "-> CppLint started..." - if [ -d ${CPPLINT_REPORT_DIR} ]; then - rm -Rf ${CPPLINT_REPORT_DIR} + if [ -d "${CPPLINT_REPORT_DIR}" ]; then + rm -Rf "${CPPLINT_REPORT_DIR}" fi - mkdir -p ${CPPLINT_REPORT_DIR} - python ${CURRENT_DIR}/cpplint.py --linelength=160 --counting=detailed --quiet --filter=" + mkdir -p "${CPPLINT_REPORT_DIR}" + python "${CURRENT_DIR}/cpplint.py" --linelength=160 --counting=detailed --quiet --filter=" -build/header_guard, -build/include, -build/include_order, @@ -32,20 +32,20 @@ function run_cpplint() { -runtime/explicit, -readability/todo, -readability/fn_size - " $(find ${SOURCE_DIR} -name '*.h' -or -name '*.cc' -or -name '*.c' -or -name '*.cpp' -or -name '*.hpp' | + " $(find "${SOURCE_DIR}" -name '*.h' -or -name '*.cc' -or -name '*.c' -or -name '*.cpp' -or -name '*.hpp' | grep -v 'inference-engine/bin\|inference-engine/build\|inference-engine/report\|inference-engine/scripts\|inference-engine/temp\|inference-engine/tests_deprecated/\|gtest\|inference-engine/ie_bridges\|pugixml\|inference-engine/tools/vpu_perfcheck\|thirdparty/gflags\|thirdparty/ade\|thirdparty/fluid\|thirdparty/mkl-dnn\|thirdparty/movidius\|thirdparty/ocv\|thirdparty/plugixml\|thirdparty/std_lib\|thirdparty/clDNN/common\|thirdparty/clDNN/tutorial\|thirdparty/clDNN/utils' | grep 'include\|src\|inference-engine/samples\|thirdparty/clDNN/kernel_selector\|thirdparty/clDNN/api\|thirdparty/clDNN/api_extension\|inference-engine/tests_' ) 2>&1 | sed 's/"/\"/g' >&1| sed 's/&1| sed 's/>/\>/g' >&1| sed "s/'/\'/g" >&1| - sed 's/\&/\&/g' >&1| python ${CURRENT_DIR}/cpplint_to_cppcheckxml.py &> ${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml + sed 's/\&/\&/g' >&1| python "${CURRENT_DIR}/cpplint_to_cppcheckxml.py" &> "${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml" - # Generate html from it - ${CURRENT_DIR}/cppcheck-htmlreport.py --file=${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml --report-dir=${CPPLINT_REPORT_DIR} --source-dir=${SOURCE_DIR} --title=${PROJECT_NAME} + # Generate html from it + "${CURRENT_DIR}/cppcheck-htmlreport.py" --file="${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml" --report-dir="${CPPLINT_REPORT_DIR}" --source-dir="${SOURCE_DIR}" --title="${PROJECT_NAME}" - # Change Cppcheck things to cpplint - sed -i.bak 's/Cppcheck/cpplint/g' ${CPPLINT_REPORT_DIR}/index.html - sed -i.bak 's/a\ tool\ for\ static\ C\/C++\ code\ analysis/an\ open\ source\ lint\-like\ tool\ from\ Google/g' ${CPPLINT_REPORT_DIR}/index.html - sed -i.bak 's/http:\/\/cppcheck.sourceforge.net/http:\/\/google\-styleguide.googlecode.com\/svn\/trunk\/cpplint\/cpplint.py/g' ${CPPLINT_REPORT_DIR}/index.html - sed -i.bak 's/IRC: irc:\/\/irc.freenode.net\/cppcheck<\/a>/\ /g' ${CPPLINT_REPORT_DIR}/index.html + # Change Cppcheck things to cpplint + sed -i.bak 's/Cppcheck/cpplint/g' "${CPPLINT_REPORT_DIR}/index.html" + sed -i.bak 's/a\ tool\ for\ static\ C\/C++\ code\ analysis/an\ open\ source\ lint\-like\ tool\ from\ Google/g' "${CPPLINT_REPORT_DIR}/index.html" + sed -i.bak 's/http:\/\/cppcheck.sourceforge.net/http:\/\/google\-styleguide.googlecode.com\/svn\/trunk\/cpplint\/cpplint.py/g' "${CPPLINT_REPORT_DIR}/index.html" + sed -i.bak 's/IRC: irc:\/\/irc.freenode.net\/cppcheck<\/a>/\ /g' "${CPPLINT_REPORT_DIR}/index.html" echo "-> CppLint finished..." } @@ -53,33 +53,33 @@ function run_cpplint() { function run_cpp_check() { echo "-> Cppcheck started..." CPPCHECK_REPORT_DIR="${REPORT_DIR}/cppcheck" - if [ -d ${CPPCHECK_REPORT_DIR} ]; then - rm -Rf ${CPPCHECK_REPORT_DIR} + if [ -d "${CPPCHECK_REPORT_DIR}" ]; then + rm -Rf "${CPPCHECK_REPORT_DIR}" fi - mkdir -p ${CPPCHECK_REPORT_DIR} + mkdir -p "${CPPCHECK_REPORT_DIR}" - # Generate cppcheck xml - cppcheck -v --enable=all --suppress=missingIncludeSystem --std=c++11 ${SOURCE_DIR} -i${SOURCE_DIR}/thirdparty -i${SOURCE_DIR}/tests/libs -i${SOURCE_DIR}/temp -i${SOURCE_DIR}/build \ - -i${SOURCE_DIR}/bin -i${SOURCE_DIR}/report -I${SOURCE_DIR}/include -I${SOURCE_DIR}/src -I${SOURCE_DIR}/thirdparty/pugixml/src -I${SOURCE_DIR}/thirdparty/gflags/src -I${SOURCE_DIR}/samples/scoring_agent/HTTPClient -I${SOURCE_DIR}/src/inference_engine --xml-version=2 2> ${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml + # Generate cppcheck xml + cppcheck -v --enable=all --suppress=missingIncludeSystem --std=c++11 "${SOURCE_DIR}" -i"${SOURCE_DIR}/thirdparty" -i"${SOURCE_DIR}/tests/libs" -i"${SOURCE_DIR}/temp" -i"${SOURCE_DIR}/build" \ + -i"${SOURCE_DIR}/bin" -i"${SOURCE_DIR}/report" -I"${SOURCE_DIR}/include" -I"${SOURCE_DIR}/src" -I"${SOURCE_DIR}/thirdparty/pugixml/src" -I"${SOURCE_DIR}/thirdparty/gflags/src" -I"${SOURCE_DIR}/samples/scoring_agent/HTTPClient" -I"${SOURCE_DIR}/src/inference_engine" --xml-version=2 2> "${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml" - # Generate html from it - python ${CURRENT_DIR}/cppcheck-htmlreport.py\ - --file=${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml\ - --report-dir=${CPPCHECK_REPORT_DIR}\ - --source-dir=${SOURCE_DIR}\ - --title=${PROJECT_NAME} + # Generate html from it + python "${CURRENT_DIR}/cppcheck-htmlreport.py" \ + --file="${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml" \ + --report-dir="${CPPCHECK_REPORT_DIR}" \ + --source-dir="${SOURCE_DIR}" \ + --title="${PROJECT_NAME}" echo "-> Cppcheck finished..." } -if [ ! -d ${REPORT_DIR} ]; then - mkdir -p ${REPORT_DIR} +if [ ! -d "${REPORT_DIR}" ]; then + mkdir -p "${REPORT_DIR}" fi run_cpplint -out_cpp_lint=`cat ${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml` -if [[ ${out_cpp_lint} == *"error"* ]]; then +out_cpp_lint=`cat "${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml"` +if [[ "${out_cpp_lint}" == *"error"* ]]; then exit 1 fi #run_cpp_check diff --git a/inference-engine/scripts/run_tests_myriad_multistick.sh b/inference-engine/scripts/run_tests_myriad_multistick.sh index c6082a9f336..74cf6d94bd6 100755 --- a/inference-engine/scripts/run_tests_myriad_multistick.sh +++ b/inference-engine/scripts/run_tests_myriad_multistick.sh @@ -31,7 +31,7 @@ else fi echo "Test directory: ${TEST_DIR}" -cd ${TEST_DIR} +cd "${TEST_DIR}" export IE_VPU_MYRIADX=1 @@ -64,7 +64,7 @@ fi # Wait for all processes to finish sts="" for p in ${pids}; do - if wait ${p}; then + if wait "${p}"; then sts+=" 1" else sts+=" 0" diff --git a/ngraph/python/tests/test_onnx/model_zoo_preprocess.sh b/ngraph/python/tests/test_onnx/model_zoo_preprocess.sh index 25a742943e4..790d15d9c7c 100644 --- a/ngraph/python/tests/test_onnx/model_zoo_preprocess.sh +++ b/ngraph/python/tests/test_onnx/model_zoo_preprocess.sh @@ -7,58 +7,58 @@ ENABLE_MSFT=false CLONE=false function print_help { - echo "Model preprocessing options:" - echo " -h display this help message" - echo " -c clone ONNX models repository" - echo " -m set location of the models" - echo " -f clean target directory(during clone or after enable MSFT models)" - echo " -e download and prepare MSFT models" + echo "Model preprocessing options:" + echo " -h display this help message" + echo " -c clone ONNX models repository" + echo " -m set location of the models" + echo " -f clean target directory(during clone or after enable MSFT models)" + echo " -e download and prepare MSFT models" } while getopts ":hcefm:" opt; do - case ${opt} in - h ) - print_help - ;; - \? ) - print_help - ;; - : ) - print_help - ;; - c ) - CLONE=true - ;; - m ) - MODELS_DIR=$OPTARG - ;; - f ) - CLEAN_DIR=true - ;; - e ) - ENABLE_MSFT=true - ;; - esac + case ${opt} in + h ) + print_help + ;; + \? ) + print_help + ;; + : ) + print_help + ;; + c ) + CLONE=true + ;; + m ) + MODELS_DIR="$OPTARG" + ;; + f ) + CLEAN_DIR=true + ;; + e ) + ENABLE_MSFT=true + ;; + esac done shift $((OPTIND -1)) -if [ $MODELS_DIR = false ] ; then - echo "Unknown location of the ZOO models" - exit 170 +if [ "$MODELS_DIR" = false ] ; then + echo "Unknown location of the ZOO models" + exit 170 fi -ONNX_MODELS_DIR=$MODELS_DIR/model_zoo/onnx_model_zoo -MSFT_MODELS_DIR=$MODELS_DIR/model_zoo/MSFT +ONNX_MODELS_DIR="$MODELS_DIR/model_zoo/onnx_model_zoo" +MSFT_MODELS_DIR="$MODELS_DIR/model_zoo/MSFT" -if [ $CLONE = true ] ; then - if [ $CLEAN_DIR = true ] ; then - rm -rf $ONNX_MODELS_DIR - fi - git clone https://github.com/onnx/models.git $ONNX_MODELS_DIR +if [ "$CLONE" = true ] ; then + if [ "$CLEAN_DIR" = true ] ; then + rm -rf "$ONNX_MODELS_DIR" + fi + git clone https://github.com/onnx/models.git "$ONNX_MODELS_DIR" fi -mkdir -p $ONNX_MODELS_DIR -cd $ONNX_MODELS_DIR +mkdir -p "$ONNX_MODELS_DIR" +cd "$ONNX_MODELS_DIR" # remove already downloaded models git clean -f -x -d git checkout . @@ -66,11 +66,11 @@ git pull -p # pull models from the lfs repository # onnx models are included in the tar.gz archives git lfs pull --include="*" --exclude="*.onnx" -find $ONNX_MODELS_DIR -name "*.onnx" | while read filename; do rm "$filename"; done; +find "$ONNX_MODELS_DIR" -name "*.onnx" | while read filename; do rm "$filename"; done; echo "extracting tar.gz archives..." -find $ONNX_MODELS_DIR -name '*.tar.gz' -execdir sh -c 'BASEDIR=$(basename "{}" .tar.gz) && mkdir -p $BASEDIR' \; -execdir sh -c 'BASEDIR=$(basename "{}" .tar.gz) && tar -xzvf "{}" -C $BASEDIR' \; +find "$ONNX_MODELS_DIR" -name '*.tar.gz' -execdir sh -c 'BASEDIR=$(basename "{}" .tar.gz) && mkdir -p $BASEDIR' \; -execdir sh -c 'BASEDIR=$(basename "{}" .tar.gz) && tar -xzvf "{}" -C $BASEDIR' \; # fix yolo v4 model -cd $ONNX_MODELS_DIR/vision/object_detection_segmentation/yolov4/model/yolov4/yolov4/test_data_set +cd "$ONNX_MODELS_DIR/vision/object_detection_segmentation/yolov4/model/yolov4/yolov4/test_data_set" mv input0.pb input_0.pb mv input1.pb input_1.pb mv input2.pb input_2.pb @@ -78,16 +78,16 @@ mv output0.pb output_0.pb mv output1.pb output_1.pb mv output2.pb output_2.pb # fix roberta model -cd $ONNX_MODELS_DIR/text/machine_comprehension/roberta/model/roberta-sequence-classification-9/roberta-sequence-classification-9 +cd "$ONNX_MODELS_DIR/text/machine_comprehension/roberta/model/roberta-sequence-classification-9/roberta-sequence-classification-9" mkdir test_data_set_0 mv *.pb test_data_set_0/ # Prepare MSFT models -if [ $ENABLE_MSFT = true ] ; then - if [ $CLEAN_DIR = true ] ; then - rm -rf $MSFT_MODELS_DIR +if [ "$ENABLE_MSFT" = true ] ; then + if [ "$CLEAN_DIR" = true ] ; then + rm -rf "$MSFT_MODELS_DIR" fi - mkdir -p $MSFT_MODELS_DIR - wget -O $MSFT_MODELS_DIR/20191107.zip https://onnxruntimetestdata.blob.core.windows.net/models/20191107.zip - unzip $MSFT_MODELS_DIR/20191107.zip -d $MSFT_MODELS_DIR/20191107 && rm $MSFT_MODELS_DIR/20191107.zip + mkdir -p "$MSFT_MODELS_DIR" + wget -O "$MSFT_MODELS_DIR/20191107.zip https://onnxruntimetestdata.blob.core.windows.net/models/20191107.zip" + unzip "$MSFT_MODELS_DIR/20191107.zip" -d "$MSFT_MODELS_DIR/20191107" && rm "$MSFT_MODELS_DIR/20191107.zip" fi diff --git a/scripts/demo/demo_benchmark_app.sh b/scripts/demo/demo_benchmark_app.sh index c0fd828ee47..97f67c58266 100755 --- a/scripts/demo/demo_benchmark_app.sh +++ b/scripts/demo/demo_benchmark_app.sh @@ -70,7 +70,7 @@ else printf "Error: setupvars.sh is not found\n" fi -if ! . $setupvars_path ; then +if ! . "$setupvars_path" ; then printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" exit 1 fi @@ -120,7 +120,7 @@ elif [[ $DISTRO == "ubuntu" ]]; then pip_binary=pip3 system_ver=`cat /etc/lsb-release | grep -i "DISTRIB_RELEASE" | cut -d "=" -f2` - if [ $system_ver = "16.04" ]; then + if [ "$system_ver" = "16.04" ]; then sudo -E apt-get install -y libpng12-dev else sudo -E apt-get install -y libpng-dev @@ -148,9 +148,9 @@ if ! command -v $python_binary &>/dev/null; then fi if [[ "$OSTYPE" == "darwin"* ]]; then - $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in + $pip_binary install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" else - sudo -E $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in + sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" fi downloader_dir="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/tools/downloader" @@ -192,7 +192,7 @@ printf "Build Inference Engine samples\n\n" OS_PATH=$(uname -m) NUM_THREADS="-j2" -if [ $OS_PATH == "x86_64" ]; then +if [ "$OS_PATH" == "x86_64" ]; then OS_PATH="intel64" NUM_THREADS="-j8" fi @@ -201,12 +201,12 @@ samples_path="${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/samples/cp build_dir="$HOME/inference_engine_samples_build" binaries_dir="${build_dir}/${OS_PATH}/Release" -if [ -e $build_dir/CMakeCache.txt ]; then - rm -rf $build_dir/CMakeCache.txt +if [ -e "$build_dir/CMakeCache.txt" ]; then + rm -rf "$build_dir/CMakeCache.txt" fi -mkdir -p $build_dir -cd $build_dir -cmake -DCMAKE_BUILD_TYPE=Release $samples_path +mkdir -p "$build_dir" +cd "$build_dir" +cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS benchmark_app @@ -214,9 +214,9 @@ make $NUM_THREADS benchmark_app printf "${dashes}" printf "Run Inference Engine benchmark app\n\n" -cd $binaries_dir +cd "$binaries_dir" -cp -f $ROOT_DIR/${model_name}.labels ${ir_dir}/ +cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc ${sampleoptions} diff --git a/scripts/demo/demo_security_barrier_camera.sh b/scripts/demo/demo_security_barrier_camera.sh index ca71a7e4ecd..568232bb3ef 100755 --- a/scripts/demo/demo_security_barrier_camera.sh +++ b/scripts/demo/demo_security_barrier_camera.sh @@ -89,7 +89,7 @@ elif [[ $DISTRO == "ubuntu" ]]; then pip_binary=pip3 system_ver=`cat /etc/lsb-release | grep -i "DISTRIB_RELEASE" | cut -d "=" -f2` - if [ $system_ver = "16.04" ]; then + if [ "$system_ver" = "16.04" ]; then sudo -E apt-get install -y libpng12-dev else sudo -E apt-get install -y libpng-dev @@ -117,9 +117,9 @@ if ! command -v $python_binary &>/dev/null; then fi if [[ $DISTRO == "macos" ]]; then - $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in + "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" else - sudo -E $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in + sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" fi if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then @@ -127,7 +127,7 @@ if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then else printf "Error: setupvars.sh is not found\n" fi -if ! . $setupvars_path ; then +if ! . "$setupvars_path" ; then printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" exit 1 fi @@ -174,18 +174,18 @@ fi OS_PATH=$(uname -m) NUM_THREADS="-j2" -if [ $OS_PATH == "x86_64" ]; then +if [ "$OS_PATH" == "x86_64" ]; then OS_PATH="intel64" NUM_THREADS="-j8" fi build_dir="$HOME/inference_engine_demos_build" -if [ -e $build_dir/CMakeCache.txt ]; then - rm -rf $build_dir/CMakeCache.txt +if [ -e "$build_dir/CMakeCache.txt" ]; then + rm -rf "$build_dir/CMakeCache.txt" fi -mkdir -p $build_dir -cd $build_dir -cmake -DCMAKE_BUILD_TYPE=Release $demos_path +mkdir -p "$build_dir" +cd "$build_dir" +cmake -DCMAKE_BUILD_TYPE=Release "$demos_path" make $NUM_THREADS security_barrier_camera_demo # Step 3. Run samples @@ -193,7 +193,7 @@ printf "${dashes}" printf "Run Inference Engine security_barrier_camera demo\n\n" binaries_dir="${build_dir}/${OS_PATH}/Release" -cd $binaries_dir +cd "$binaries_dir" print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" ${sampleoptions} diff --git a/scripts/demo/demo_squeezenet_download_convert_run.sh b/scripts/demo/demo_squeezenet_download_convert_run.sh index 86e1e3286da..7e173cf7bb1 100755 --- a/scripts/demo/demo_squeezenet_download_convert_run.sh +++ b/scripts/demo/demo_squeezenet_download_convert_run.sh @@ -66,7 +66,7 @@ else printf "Error: setupvars.sh is not found\n" fi -if ! . $setupvars_path ; then +if ! . "$setupvars_path" ; then printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" exit 1 fi @@ -116,7 +116,7 @@ elif [[ $DISTRO == "ubuntu" ]]; then pip_binary=pip3 system_ver=`cat /etc/lsb-release | grep -i "DISTRIB_RELEASE" | cut -d "=" -f2` - if [ $system_ver = "16.04" ]; then + if [ "$system_ver" = "16.04" ]; then sudo -E apt-get install -y libpng12-dev else sudo -E apt-get install -y libpng-dev @@ -144,9 +144,9 @@ if ! command -v $python_binary &>/dev/null; then fi if [[ "$OSTYPE" == "darwin"* ]]; then - $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in + "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" else - sudo -E $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in + sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" fi downloader_dir="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/tools/downloader" @@ -188,7 +188,7 @@ printf "Build Inference Engine samples\n\n" OS_PATH=$(uname -m) NUM_THREADS="-j2" -if [ $OS_PATH == "x86_64" ]; then +if [ "$OS_PATH" == "x86_64" ]; then OS_PATH="intel64" NUM_THREADS="-j8" fi @@ -197,12 +197,12 @@ samples_path="${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/samples/cp build_dir="$HOME/inference_engine_samples_build" binaries_dir="${build_dir}/${OS_PATH}/Release" -if [ -e $build_dir/CMakeCache.txt ]; then - rm -rf $build_dir/CMakeCache.txt +if [ -e "$build_dir/CMakeCache.txt" ]; then + rm -rf "$build_dir/CMakeCache.txt" fi -mkdir -p $build_dir -cd $build_dir -cmake -DCMAKE_BUILD_TYPE=Release $samples_path +mkdir -p "$build_dir" +cd "$build_dir" +cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS classification_sample_async @@ -210,9 +210,9 @@ make $NUM_THREADS classification_sample_async printf "${dashes}" printf "Run Inference Engine classification sample\n\n" -cd $binaries_dir +cd "$binaries_dir" -cp -f $ROOT_DIR/${model_name}.labels ${ir_dir}/ +cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" ${sampleoptions} diff --git a/scripts/install_dependencies/install_NCS_udev_rules.sh b/scripts/install_dependencies/install_NCS_udev_rules.sh index 029e12ddb23..aac8c2510ae 100755 --- a/scripts/install_dependencies/install_NCS_udev_rules.sh +++ b/scripts/install_dependencies/install_NCS_udev_rules.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # Copyright (c) 2018-2019 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/install_dependencies/install_NEO_OCL_driver.sh b/scripts/install_dependencies/install_NEO_OCL_driver.sh index 242e60f06e0..7569eb031fb 100755 --- a/scripts/install_dependencies/install_NEO_OCL_driver.sh +++ b/scripts/install_dependencies/install_NEO_OCL_driver.sh @@ -47,12 +47,12 @@ _install_prerequisites_centos() "yum -y install rpmdevtools openssl openssl-devel bc numactl ocl-icd ocl-icd-devel") for cmd in "${CMDS[@]}"; do - echo $cmd - eval $cmd + echo "$cmd" + eval "$cmd" if [[ $? -ne 0 ]]; then - echo ERROR: failed to run $cmd >&2 - echo Problem \(or disk space\)? >&2 - echo . Verify that you have enough disk space, and run the script again. >&2 + echo "ERROR: failed to run $cmd" >&2 + echo "Problem (or disk space)?" >&2 + echo ". Verify that you have enough disk space, and run the script again." >&2 exit $EXIT_FAILURE fi done @@ -65,13 +65,13 @@ _install_prerequisites_ubuntu() "apt-get -y install libnuma1 ocl-icd-libopencl1") for cmd in "${CMDS[@]}"; do - echo $cmd - eval $cmd + echo "$cmd" + eval "$cmd" if [[ $? -ne 0 ]]; then - echo ERROR: failed to run $cmd >&2 - echo Problem \(or disk space\)? >&2 + echo "ERROR: failed to run $cmd" >&2 + echo "Problem (or disk space)?" >&2 echo " sudo -E $0" >&2 - echo 2. Verify that you have enough disk space, and run the script again. >&2 + echo "2. Verify that you have enough disk space, and run the script again." >&2 exit $EXIT_FAILURE fi done @@ -98,15 +98,15 @@ _deploy_rpm() # IGFX_RPM_FLAGS="--force" sudo -E ./install_NEO_OCL_driver.sh install # cmd="rpm $IGFX_RPM_FLAGS -ivh --nodeps --force $1" - echo $cmd - eval $cmd + echo "$cmd" + eval "$cmd" } _deploy_deb() { cmd="dpkg -i $1" - echo $cmd - eval $cmd + echo "$cmd" + eval "$cmd" } @@ -114,8 +114,8 @@ _install_user_mode_centos() { _deploy_rpm "intel*.rpm" if [[ $? -ne 0 ]]; then - echo ERROR: failed to install rpms $cmd error >&2 - echo Make sure you have enough disk space or fix the problem manually and try again. >&2 + echo "ERROR: failed to install rpms $cmd error" >&2 + echo "Make sure you have enough disk space or fix the problem manually and try again." >&2 exit $EXIT_FAILURE fi } @@ -124,8 +124,8 @@ _install_user_mode_ubuntu() { _deploy_deb "intel*.deb" if [[ $? -ne 0 ]]; then - echo ERROR: failed to install rpms $cmd error >&2 - echo Make sure you have enough disk space or fix the problem manually and try again. >&2 + echo "ERROR: failed to install rpms $cmd error" >&2 + echo "Make sure you have enough disk space or fix the problem manually and try again." >&2 exit $EXIT_FAILURE fi } @@ -143,7 +143,7 @@ install_user_mode() # exit from $SCRIPT_DIR/neo folder cd - # clean it up - rm -rf $SCRIPT_DIR/neo + rm -rf "$SCRIPT_DIR/neo" } _uninstall_user_mode_centos() @@ -156,12 +156,12 @@ _uninstall_user_mode_centos() "intel-igc-opencl") for package in "${PACKAGES[@]}"; do echo "rpm -qa | grep $package" - found_package=$(rpm -qa | grep $package) + found_package=$(rpm -qa | grep "$package") if [[ $? -eq 0 ]]; then echo "Found installed user-mode driver, performing uninstall..." cmd="rpm -e --nodeps ${found_package}" - echo $cmd - eval $cmd + echo "$cmd" + eval "$cmd" if [[ $? -ne 0 ]]; then echo "ERROR: failed to uninstall existing user-mode driver." >&2 echo "Please try again manually and run the script again." >&2 @@ -182,12 +182,12 @@ _uninstall_user_mode_ubuntu() "intel-igc-opencl") for package in "${PACKAGES[@]}"; do - found_package=$(dpkg-query -W -f='${binary:Package}\n' ${package}) + found_package=$(dpkg-query -W -f='${binary:Package}\n' "${package}") if [[ $? -eq 0 ]]; then echo "Found installed user-mode driver, performing uninstall..." cmd="apt-get autoremove -y $package" - echo $cmd - eval $cmd + echo "$cmd" + eval "$cmd" if [[ $? -ne 0 ]]; then echo "ERROR: failed to uninstall existing user-mode driver." >&2 echo "Please try again manually and run the script again." >&2 @@ -213,8 +213,8 @@ _is_package_installed() else cmd="dpkg-query -W -f='${binary:Package}\n' $pkg" fi - echo $cmd - eval $cmd + echo "$cmd" + eval "$cmd" } @@ -246,7 +246,7 @@ _verify_checksum_ubuntu() _verify_checksum_centos() { - sha1sum -c $SCRIPT_DIR/neo_centos_ww41.sum + sha1sum -c "$SCRIPT_DIR/neo_centos_ww41.sum" } verify_checksum() @@ -260,8 +260,8 @@ verify_checksum() download_packages() { - mkdir -p $SCRIPT_DIR/neo - cd $SCRIPT_DIR/neo + mkdir -p "$SCRIPT_DIR/neo" + cd "$SCRIPT_DIR/neo" if [[ $DISTRO == "centos" ]]; then _download_packages_centos @@ -312,19 +312,19 @@ check_root_access() { if [[ $EUID -ne 0 ]]; then echo "ERROR: you must run this script as root." >&2 - echo "Please try again with "sudo -E $0", or as root." >&2 + echo "Please try again with \"sudo -E $0\", or as root." >&2 exit $EXIT_FAILURE fi } add_user_to_video_group() { - local real_user=$(logname 2>/dev/null || echo ${SUDO_USER:-${USER}}) + local real_user=$(logname 2>/dev/null || echo "${SUDO_USER:-${USER}}") echo - echo Adding $real_user to the video group... - usermod -a -G video $real_user + echo "Adding $real_user to the video group..." + usermod -a -G video "$real_user" if [[ $? -ne 0 ]]; then - echo WARNING: unable to add $real_user to the video group >&2 + echo "WARNING: unable to add $real_user to the video group" >&2 fi } @@ -333,8 +333,8 @@ _check_distro_version() if [[ $DISTRO == centos ]]; then CENTOS_MINOR=$(sed 's/CentOS Linux release 7\.\([[:digit:]]\+\).\+/\1/' /etc/centos-release) if [[ $? -ne 0 ]]; then - echo ERROR: failed to obtain CentOS version minor. >&2 - echo This script is supported only on CentOS 7 and above. >&2 + echo "ERROR: failed to obtain CentOS version minor." >&2 + echo "This script is supported only on CentOS 7 and above." >&2 exit $EXIT_FAILURE fi elif [[ $DISTRO == ubuntu ]]; then diff --git a/scripts/setupvars/setupvars.sh b/scripts/setupvars/setupvars.sh index ec444b56176..6430d7749a0 100755 --- a/scripts/setupvars/setupvars.sh +++ b/scripts/setupvars/setupvars.sh @@ -112,13 +112,13 @@ fi MINIMUM_REQUIRED_PYTHON_VERSION="3.6" MAX_SUPPORTED_PYTHON_VERSION=$([[ "$OSTYPE" == "darwin"* ]] && echo '3.7' || echo '3.8') -if [[ ! -z "$python_version" && "$(printf '%s\n' "$python_version" "$MINIMUM_REQUIRED_PYTHON_VERSION" | sort -V | head -n 1)" != "$MINIMUM_REQUIRED_PYTHON_VERSION" ]]; then +if [[ -n "$python_version" && "$(printf '%s\n' "$python_version" "$MINIMUM_REQUIRED_PYTHON_VERSION" | sort -V | head -n 1)" != "$MINIMUM_REQUIRED_PYTHON_VERSION" ]]; then echo "[setupvars.sh] ERROR: Unsupported Python version. Please install one of Python 3.6-${MAX_SUPPORTED_PYTHON_VERSION} (64-bit) from https://www.python.org/downloads/" return 1 fi -if [ ! -z "$python_version" ]; then +if [ -n "$python_version" ]; then # add path to OpenCV API for Python 3.x export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python3:$PYTHONPATH" pydir=$INTEL_OPENVINO_DIR/python/python$python_version