From: Arnaud Giersch Date: Sat, 7 Dec 2019 22:16:13 +0000 (+0100) Subject: Fix portability issues in shellscripts (codefactor.io/ShellCheck). X-Git-Tag: v3.25~323 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/dce51a171761c0f221ee10beecf3f9ead9bbb627?ds=sidebyside Fix portability issues in shellscripts (codefactor.io/ShellCheck). --- diff --git a/BuildSimGrid.sh b/BuildSimGrid.sh index 811199fad2..4bb2f7a878 100755 --- a/BuildSimGrid.sh +++ b/BuildSimGrid.sh @@ -18,7 +18,7 @@ fi target=tests install_path=$(sed -n 's/^CMAKE_INSTALL_PREFIX:PATH=//p' CMakeCache.txt) -if [ -e ${install_path} -a -d ${install_path} -a -x ${install_path} -a -w ${install_path} ] ; then +if [ -e ${install_path} ] && [ -d ${install_path} ] && [ -x ${install_path} ] && [ -w ${install_path} ] ; then target=install fi diff --git a/docs/Build.sh b/docs/Build.sh index 6ef952ae57..3a28d289f8 100755 --- a/docs/Build.sh +++ b/docs/Build.sh @@ -7,14 +7,14 @@ if [ -e /opt/simgrid ] ; then chmod +x /opt/simgrid; fi set -e -if [ "x$1" != 'xdoxy' -a -e build/xml ] ; then +if [ "x$1" != 'xdoxy' ] && [ -e build/xml ] ; then echo "Doxygen not rerun: 'doxy' was not provided as an argument" else rm -rf build/xml source/api/ cd source; doxygen; cd .. fi -if [ "x$1" != 'xjava' -a -e source/java ] ; then +if [ "x$1" != 'xjava' ] && [ -e source/java ] ; then echo "javasphinx not rerun: 'java' was not provided as an argument" else rm -rf source/java @@ -23,7 +23,7 @@ else rm -f source/java/org/simgrid/msg/package-index.rst # api_generated/source_java_org_simgrid_msg_package-index.rst for f in source/java/org/simgrid/msg/* ; do # Add the package name to the page titles - (echo -n "class org.simgrid.msg."; cat $f )>tmp + (printf "class org.simgrid.msg."; cat $f )>tmp mv tmp $f sed -i 's/==/========================/' $f # That's the right length knowing that I add 'class org.simgrid.msg.' done diff --git a/examples/smpi/replay_multiple/generate_multiple_deployment.sh b/examples/smpi/replay_multiple/generate_multiple_deployment.sh index 3cf7463e03..62a3fa3751 100755 --- a/examples/smpi/replay_multiple/generate_multiple_deployment.sh +++ b/examples/smpi/replay_multiple/generate_multiple_deployment.sh @@ -124,7 +124,7 @@ DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1) if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then IFS_OLD=$IFS - IFS=$'\n' + IFS=$(printf '\n_'); IFS=${IFS%_} # protect trailing \n set -f NUMPROCS=0 while IFS= read -r line; do @@ -149,7 +149,7 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then SEQ1=$( ${HAVE_SEQ} 0 $(( NUMPROCSMINE - 1 )) ) else cnt=0 - while (( cnt < NUMPROCSMINE )) ; do + while [ $(( cnt < NUMPROCSMINE )) -ne 0 ]; do SEQ1="$SEQ1 $cnt" cnt=$((cnt + 1)) done @@ -186,7 +186,7 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then done # return IFS back to newline for "for" loop IFS_OLD=$IFS - IFS=$'\n' + IFS=$(printf '\n_'); IFS=${IFS%_} # protect trailing \n done < ${DESCRIPTIONFILE} # return delimiter to previous value diff --git a/tools/internal/travis-sonarqube.sh b/tools/internal/travis-sonarqube.sh index 94b05c8e24..eeb0b44051 100755 --- a/tools/internal/travis-sonarqube.sh +++ b/tools/internal/travis-sonarqube.sh @@ -11,7 +11,7 @@ set -ex # Install required software installSonarQubeScanner() { - local SONAR_SCANNER_VERSION=3.2.0.1227 + SONAR_SCANNER_VERSION=3.2.0.1227 export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION rm -rf $SONAR_SCANNER_HOME mkdir -p $SONAR_SCANNER_HOME diff --git a/tools/jenkins/DynamicAnalysis_description.sh b/tools/jenkins/DynamicAnalysis_description.sh index a052a8f809..8e513360e6 100755 --- a/tools/jenkins/DynamicAnalysis_description.sh +++ b/tools/jenkins/DynamicAnalysis_description.sh @@ -7,7 +7,7 @@ wget https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis-Valgrind/label=simg #find string containing errors and leaked size for valgrind run wget https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis-Valgrind/label=simgrid-debian8-64-dynamic-analysis/lastCompletedBuild/ -VALGRIND_RES=$(grep href\=\"valgrindResult\" ./index.html | sed -e "s/.*\"valgrindResult\">\(.*lost\)<\/a.*/\1/g") +VALGRIND_RES=$(grep href=\"valgrindResult\" ./index.html | sed -e "s/.*\"valgrindResult\">\(.*lost\)<\/a.*/\1/g") rm index.html #set html description and write it in a file diff --git a/tools/jenkins/Flags.sh b/tools/jenkins/Flags.sh index 40d12dff74..35f5bc4ecc 100755 --- a/tools/jenkins/Flags.sh +++ b/tools/jenkins/Flags.sh @@ -2,14 +2,6 @@ set -e -if [ $# -lt 4 ] - then - echo "Needs 4 arguments : JAVA MC SMPI DEBUG" - exit -1 -fi - - - die() { echo "$@" exit 1 @@ -34,6 +26,8 @@ onoff() { fi } +[ $# -eq 4 ] || die "Needs 4 arguments : JAVA MC SMPI DEBUG" + ### Cleanup previous runs ! [ -z "$WORKSPACE" ] || die "No WORKSPACE" diff --git a/tools/jenkins/build.sh b/tools/jenkins/build.sh index 621d8e8832..73fc613134 100755 --- a/tools/jenkins/build.sh +++ b/tools/jenkins/build.sh @@ -14,7 +14,7 @@ echo "XXXX Cleanup previous attempts. Remaining content of /tmp:" rm -rf /tmp/simgrid-java* rm -rf /var/tmp/simgrid-java* rm -rf /tmp/jvm-* -find /builds/workspace/SimGrid/ -name "hs_err_pid*.log" | xargs rm -f +find /builds/workspace/SimGrid/ -name "hs_err_pid*.log" -exec rm -f {} + ls /tmp df -h echo "XXXX Let's go" @@ -191,7 +191,7 @@ else MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON" fi -if [ "$os" = "NixOS" -a "$(gcc -dumpversion)" = "7.4.0" ]; then +if [ "$os" = "NixOS" ] && [ "$(gcc -dumpversion)" = "7.4.0" ]; then echo "Temporary disable LTO, believed to be broken on this system." MAY_DISABLE_LTO=-Denable_lto=OFF else