From 19dbf4e48f3cce90470708c82468657fba8c88c7 Mon Sep 17 00:00:00 2001 From: SONOLET Aymeric Date: Tue, 19 Dec 2023 17:47:26 +0100 Subject: [PATCH] format(sh): format shell scripts, leaving errors and warnings raised by shellcheck --- eclipse.sh | 2 +- env_linux.sh | 11 +++--- findDOSfiles.sh | 24 ++++++------ findEndLines.sh | 30 +++++++-------- find_duplicated_images.sh | 48 ++++++++++++------------ launcher_env.sh | 4 +- launcher_salome_env.sh | 4 +- lcov_reports.sh | 30 +++++++-------- make.sh | 59 +++++++++++++++-------------- salome_run.sh | 12 +++--- solver.sh | 48 ++++++++++++------------ squishide_run.sh | 5 ++- src/XAO/tests/coverage_report.sh | 13 ++----- test.sh | 6 +-- test_squish.sh | 28 +++++++------- vnc-run | 64 +++++++++++++++++++++----------- 16 files changed, 201 insertions(+), 187 deletions(-) diff --git a/eclipse.sh b/eclipse.sh index 7bfacff03..e21275007 100755 --- a/eclipse.sh +++ b/eclipse.sh @@ -15,4 +15,4 @@ CMAKE_ARGS="${CMAKE_ARGS} ${SOURCES_DIR}" cmake -G "Eclipse CDT4 - Unix Makefiles" ${CMAKE_ARGS} -/dn48/newgeom/common/eclipse-4.4.0/eclipse& +/dn48/newgeom/common/eclipse-4.4.0/eclipse & diff --git a/env_linux.sh b/env_linux.sh index 5dbe200ba..fd7f181dc 100644 --- a/env_linux.sh +++ b/env_linux.sh @@ -6,11 +6,12 @@ # SHAPER_ROOT_DIR - path of SHAPER installation for path in SHAPER_PDIR SHAPER_ROOT_DIR; do - if [[ -z ${!path+x} ]]; then - echo "${path} not found."; exit 1 - else - echo "Found ${path}: ${!path}" - fi + if [[ -z ${!path+x} ]]; then + echo "${path} not found." + exit 1 + else + echo "Found ${path}: ${!path}" + fi done #------ lcov ------ diff --git a/findDOSfiles.sh b/findDOSfiles.sh index c85ea0068..00a2a5209 100755 --- a/findDOSfiles.sh +++ b/findDOSfiles.sh @@ -1,26 +1,24 @@ #!/bin/bash -function isDOSFile -{ - local FILENAME="$1" - file "$FILENAME" | grep -q "CRLF line terminators" +function isDOSFile { + local FILENAME="$1" + file "$FILENAME" | grep -q "CRLF line terminators" } -if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then - against=HEAD +if git-rev-parse --verify HEAD >/dev/null 2>&1; then + against=HEAD else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi # Find files with DOS line endings FOUND=0 -for FILE in $(exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | sed -r 's/:[0-9]+:.*//' | uniq) ; do +for FILE in $(exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | sed -r 's/:[0-9]+:.*//' | uniq); do isDOSFile "$FILE" - if (( $? == 0 )) - then - echo "\"$FILE\" has DOS line endings" >&2 - FOUND=1 + if (($? == 0)); then + echo "\"$FILE\" has DOS line endings" >&2 + FOUND=1 fi done diff --git a/findEndLines.sh b/findEndLines.sh index 10e8377f4..db60243c6 100755 --- a/findEndLines.sh +++ b/findEndLines.sh @@ -2,31 +2,31 @@ FIX_LINE_ENDINGS=0 while [[ $# > 0 ]]; do - key="$1" + key="$1" - case $key in + case $key in fix) - FIX_LINE_ENDINGS=1 - shift - ;; + FIX_LINE_ENDINGS=1 + shift + ;; *) - shift - ;; - esac + shift + ;; + esac done source env.sh -find . \( -name "*.h" -o -name "*.cpp" \) -exec cpplint.py --filter=-,+whitespace/end_of_line --verbose=0 --counting=detailed {} \+ 2>&1 | grep -v Done | tee ./tofix +find . \( -name "*.h" -o -name "*.cpp" \) -exec cpplint.py --filter=-,+whitespace/end_of_line --verbose=0 --counting=detailed {} \+ 2>&1 | grep -v Done | tee ./tofix WRONG=0 if [ -s ./tofix ]; then - if [[ ${FIX_LINE_ENDINGS} == 1 ]]; then - python correction_auto_2.py --cpplint_output_file ./tofix - echo "NOTE: Line endings are fixed" - else - WRONG=1 - fi + if [[ ${FIX_LINE_ENDINGS} == 1 ]]; then + python correction_auto_2.py --cpplint_output_file ./tofix + echo "NOTE: Line endings are fixed" + else + WRONG=1 + fi fi rm ./tofix diff --git a/find_duplicated_images.sh b/find_duplicated_images.sh index 0c9ea4136..81bbac686 100755 --- a/find_duplicated_images.sh +++ b/find_duplicated_images.sh @@ -1,7 +1,6 @@ #!/bin/bash -find_duplicated_images_usage() -{ +find_duplicated_images_usage() { echo "Find duplicated images." echo echo "Usage: $(basename ${0}) [options]" @@ -14,30 +13,31 @@ find_duplicated_images_usage() exit 0 } - - -find_duplicated_images_main() -{ +find_duplicated_images_main() { local verbose=0 local where=$(readlink -f $(dirname "${0}")) # parse command line local option - while getopts ":-:hp" option ${@} - do - if [ "${option}" = "-" ] - then + while getopts ":-:hp" option ${@}; do + if [ "${option}" = "-" ]; then case ${OPTARG} in - help ) find_duplicated_images_usage ;; - print ) verbose=1 ;; - * ) echo "Wrong option: --${OPTARG}" > /dev/stderr ; exit 1 ;; + help) find_duplicated_images_usage ;; + print) verbose=1 ;; + *) + echo "Wrong option: --${OPTARG}" >/dev/stderr + exit 1 + ;; esac else case ${option} in - h ) find_duplicated_images_usage ;; - p ) verbose=1 ;; - ? ) echo "Wrong option" > /dev/stderr ; exit 1 ;; + h) find_duplicated_images_usage ;; + p) verbose=1 ;; + ?) + echo "Wrong option" >/dev/stderr + exit 1 + ;; esac fi done @@ -45,16 +45,14 @@ find_duplicated_images_main() local result=0 - if [ "${verbose}" = "1" ] - then - local filename - for filename in $(find ${where} -type f -wholename "*/doc/*.png" -exec basename {} \; | sort | uniq -d) - do - find ${where} -type f -wholename "*/doc/*/${filename}" - result=$((result+1)) - done + if [ "${verbose}" = "1" ]; then + local filename + for filename in $(find ${where} -type f -wholename "*/doc/*.png" -exec basename {} \; | sort | uniq -d); do + find ${where} -type f -wholename "*/doc/*/${filename}" + result=$((result + 1)) + done else - result=$(find -type f -wholename "*/doc/*.png" -exec basename {} \; | sort | uniq -d | wc -l) + result=$(find -type f -wholename "*/doc/*.png" -exec basename {} \; | sort | uniq -d | wc -l) fi return ${result} diff --git a/launcher_env.sh b/launcher_env.sh index d6084d850..ad6736c8b 100755 --- a/launcher_env.sh +++ b/launcher_env.sh @@ -7,7 +7,7 @@ export PATH=${SHAPER_ROOT_DIR}/bin:${PATH} cd ${BUILD_DIR} if [[ -n $@ ]]; then - $@ + $@ else - bash + bash fi diff --git a/launcher_salome_env.sh b/launcher_salome_env.sh index 3dc1cfd51..7a500f21a 100755 --- a/launcher_salome_env.sh +++ b/launcher_salome_env.sh @@ -5,7 +5,7 @@ source env.sh cd ${BUILD_DIR} if [[ -n $@ ]]; then - $@ + $@ else - bash + bash fi diff --git a/lcov_reports.sh b/lcov_reports.sh index e2b48e3ca..566ac24de 100755 --- a/lcov_reports.sh +++ b/lcov_reports.sh @@ -10,8 +10,8 @@ lcov --capture --directory ${BUILD_DIR} --no-external --base-directory ${SOURCES cp -f coverage.info.noext covfile # remove all reports of GUI and external parts (for all the next kinds of reports) for MASK in '*wrap*' 'moc_*' 'XAO_*' 'SketcherPrs_*' 'GeomAlgoImpl_*' 'ModuleBase_*' '*Widget*' '*Splitter*'; do -lcov -r covfile ${MASK} --output-file covfile_res -q -mv -f covfile_res covfile + lcov -r covfile ${MASK} --output-file covfile_res -q + mv -f covfile_res covfile done ALL='BuildPlugin CollectionPlugin ConstructionPlugin ExchangePlugin FiltersPlugin FeaturesPlugin GDMLPlugin PrimitivesPlugin InitializationPlugin ParametersPlugin PartSetPlugin SketchPlugin' @@ -23,24 +23,23 @@ cp -f covfile covAPI # remove all plugins data except the needed NEED='BuildAPI CollectionAPI ConnectorAPI ConstructionAPI ExchangeAPI FiltersAPI FeaturesAPI ModelHighAPI ParametersAPI PartSetAPI PrimitivesAPI SketchAPI' for MASK in $ALL; do - if ! [[ " $NEED " =~ " $MASK " ]]; then - lcov -r covAPI *${MASK}* --output-file covAPI_res -q - mv -f covAPI_res covAPI - fi + if ! [[ " $NEED " =~ " $MASK " ]]; then + lcov -r covAPI *${MASK}* --output-file covAPI_res -q + mv -f covAPI_res covAPI + fi done rm -rf lcov_htmlAPI genhtml covAPI --output-directory lcov_htmlAPI -q - # prepare Direct report cp -f covfile covDirect # remove all plugins data except the needed NEED='GeomAlgoAPI GeomAPI' for MASK in $ALL; do - if ! [[ " $NEED " =~ " $MASK " ]]; then - lcov -r covDirect *${MASK}* --output-file covDirect_res -q - mv -f covDirect_res covDirect - fi + if ! [[ " $NEED " =~ " $MASK " ]]; then + lcov -r covDirect *${MASK}* --output-file covDirect_res -q + mv -f covDirect_res covDirect + fi done # exclude GeomAPI_AISObject as GUI-related object lcov -r covDirect GeomAPI_AISObject* --output-file covDirect_res -q @@ -53,16 +52,15 @@ mv -f covDirect_res covDirect rm -rf lcov_htmlDirect genhtml covDirect --output-directory lcov_htmlDirect -q - # prepare Else report cp -f covfile covElse # remove all plugins data except the needed NEED='BuildPlugin CollectionPlugin Config ConstructionPlugin Events ExchangePlugin FiltersPlugin FeaturesPlugin GeomData GeomDataAPI GeomValidators InitializationPlugin Model_ ModelAPI ModelGeomAlgo ParametersPlugin PartSetPlugin PrimitivesPlugin Selector SketchPlugin SketchSolver' for MASK in $ALL; do - if ! [[ " $NEED " =~ " $MASK " ]]; then - lcov -r covElse *${MASK}* --output-file covElse_res -q - mv -f covElse_res covElse - fi + if ! [[ " $NEED " =~ " $MASK " ]]; then + lcov -r covElse *${MASK}* --output-file covElse_res -q + mv -f covElse_res covElse + fi done rm -rf lcov_htmlElse genhtml covElse --output-directory lcov_htmlElse -q diff --git a/make.sh b/make.sh index 49d78c1f4..de97ea9ca 100755 --- a/make.sh +++ b/make.sh @@ -1,43 +1,42 @@ #!/bin/bash while [[ $# > 0 ]]; do - key="$1" - - case $key in - debug|Debug) - BUILD_TYPE=Debug - shift - ;; - lcov|coverage) - BUILD_TYPE=Debug - USE_TEST_COVERAGE=ON - shift - ;; - models|test-models) - ADD_MODELS_TESTS=TRUE - shift - ;; - compatibility|test-compatibility) - ADD_COMPATIBILITY_TESTS=TRUE - shift - ;; - hdf|test-hdf-models) - ADD_HDF_TESTS=TRUE - shift - ;; + key="$1" + + case $key in + debug | Debug) + BUILD_TYPE=Debug + shift + ;; + lcov | coverage) + BUILD_TYPE=Debug + USE_TEST_COVERAGE=ON + shift + ;; + models | test-models) + ADD_MODELS_TESTS=TRUE + shift + ;; + compatibility | test-compatibility) + ADD_COMPATIBILITY_TESTS=TRUE + shift + ;; + hdf | test-hdf-models) + ADD_HDF_TESTS=TRUE + shift + ;; *) - shift - ;; - esac + shift + ;; + esac done ## Preserve PTHONPATH in order to avoid problems with Sphinx on Fedora26 because of Pigments in ParaView export PYTHONPATH_OLD=$PYTHONPATH source env.sh -if [[ ${OS_NAME} = Fedora26-64 ]] -then - export PYTHONPATH=$PYTHONPATH_OLD +if [[ ${OS_NAME} == Fedora26-64 ]]; then + export PYTHONPATH=$PYTHONPATH_OLD fi CMAKE_ARGS="" diff --git a/salome_run.sh b/salome_run.sh index 07e15e479..282484390 100755 --- a/salome_run.sh +++ b/salome_run.sh @@ -6,15 +6,15 @@ ${TOOLS_DIR}/solver.sh "$@" # kill processes of previous SALOME run if [ -f .salomeport ]; then - SALOME_PORT=$(cat .salomeport) - ${KERNEL_ROOT_DIR}/bin/salome/killSalomeWithPort.py ${SALOME_PORT} - pkill -f "omniNames -start ${SALOME_PORT}" - rm .salomeport + SALOME_PORT=$(cat .salomeport) + ${KERNEL_ROOT_DIR}/bin/salome/killSalomeWithPort.py ${SALOME_PORT} + pkill -f "omniNames -start ${SALOME_PORT}" + rm .salomeport fi SALOME_ARGS="" -if [[ "${SALOME_SQUISH_PREFS:-FALSE}" == "TRUE" ]]; then - SALOME_ARGS="${SALOME_ARGS} -r ${SOURCES_DIR}/test.squish/shared/testdata/SalomeApp.xml" +if [[ ${SALOME_SQUISH_PREFS:-FALSE} == "TRUE" ]]; then + SALOME_ARGS="${SALOME_ARGS} -r ${SOURCES_DIR}/test.squish/shared/testdata/SalomeApp.xml" fi SALOME_ARGS="${SALOME_ARGS} --ns-port-log=$(pwd)/.salomeport" diff --git a/solver.sh b/solver.sh index 39fdda42d..d22cb8bbb 100755 --- a/solver.sh +++ b/solver.sh @@ -5,35 +5,35 @@ export PLUGINS_PATH=${PLUGINS_PATH:-${SHAPER_ROOT_DIR}/share/salome/resources/shaper/plugins.xml} while [[ $# > 0 ]]; do - key="$1" - case $key in - solvespace|ss) - export solver=SolveSpace - shift - ;; - planegcs|gcs) - export solver=PlaneGCS - shift - ;; + key="$1" + case $key in + solvespace | ss) + export solver=SolveSpace + shift + ;; + planegcs | gcs) + export solver=PlaneGCS + shift + ;; -p) - export PLUGINS_PATH="$2" - shift - shift - ;; + export PLUGINS_PATH="$2" + shift + shift + ;; *) - shift - ;; - esac + shift + ;; + esac done if [[ -z ${solver:-} ]]; then exit 0; fi case $solver in - PlaneGCS) +PlaneGCS) export SWITCH_ON=PlaneGCSSolver export SWITCH_OFF=SolveSpaceSolver ;; - SolveSpace|*) +SolveSpace | *) export SWITCH_ON=SolveSpaceSolver export SWITCH_OFF=PlaneGCSSolver ;; @@ -41,10 +41,10 @@ esac echo "Switch $solver solver in ${PLUGINS_PATH}" -cat ${PLUGINS_PATH} \ - | tr '\n' '\r' \ - | sed -e "s|\r \r