Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix portability issues in shellscripts (codefactor.io/ShellCheck).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 7 Dec 2019 22:16:13 +0000 (23:16 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 8 Dec 2019 21:31:09 +0000 (22:31 +0100)
BuildSimGrid.sh
docs/Build.sh
examples/smpi/replay_multiple/generate_multiple_deployment.sh
tools/internal/travis-sonarqube.sh
tools/jenkins/DynamicAnalysis_description.sh
tools/jenkins/Flags.sh
tools/jenkins/build.sh

index 811199f..4bb2f7a 100755 (executable)
@@ -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
 
index 6ef952a..3a28d28 100755 (executable)
@@ -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
index 3cf7463..62a3fa3 100755 (executable)
@@ -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
index 94b05c8..eeb0b44 100755 (executable)
@@ -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
index a052a8f..8e51336 100755 (executable)
@@ -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
index 40d12df..35f5bc4 100755 (executable)
@@ -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"
index 621d8e8..73fc613 100755 (executable)
@@ -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