From 16d1cb426abd8308aef19abfa28e1c2eb6ba0561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=BCtt?= Date: Wed, 10 Mar 2021 13:24:42 +0100 Subject: [PATCH] Fix remaining shellcheck errors --- tools/autotools/autogen.sh | 2 +- tools/conventions/test_conventions.sh | 8 ++--- tools/doxify/doxify.sh | 7 ++--- tools/doxify/generate_doxygen.sh | 8 ++--- tools/formatting/test_formatting.sh | 45 --------------------------- tools/plan_mpi_omp/plan.sh | 24 +++++++------- tools/precommit/deploy.sh | 10 +++--- 7 files changed, 29 insertions(+), 75 deletions(-) delete mode 100755 tools/formatting/test_formatting.sh mode change 100755 => 100644 tools/precommit/deploy.sh diff --git a/tools/autotools/autogen.sh b/tools/autotools/autogen.sh index f18dca7991..fa48ee725c 100755 --- a/tools/autotools/autogen.sh +++ b/tools/autotools/autogen.sh @@ -4,7 +4,7 @@ rm -rf autom4te.cache rm -f aclocal.m4 ltmain.sh echo "Running aclocal..." -aclocal $ACLOCAL_FLAGS -I m4 || exit 1 +aclocal "$ACLOCAL_FLAGS" -I m4 || exit 1 echo "Running autoheader..." autoheader || exit 1 echo "Running autoconf..." diff --git a/tools/conventions/test_conventions.sh b/tools/conventions/test_conventions.sh index 3e2b769663..bf7a8d994f 100755 --- a/tools/conventions/test_conventions.sh +++ b/tools/conventions/test_conventions.sh @@ -17,20 +17,20 @@ date --utc --rfc-3339=seconds ) MAKE_EXIT_CODE=$? -if (($MAKE_EXIT_CODE)); then +if ((MAKE_EXIT_CODE)); then cd ../../obj/local_warn/psmp/ echo "" - grep -B 2 Error *.warn + grep -B 2 Error ./*.warn echo "" echo "Summary: Compilation failed." echo "Status: FAILED" else - rm -f *.issues + rm -f ./*.issues set -o errexit ./analyze_gfortran_ast.py ../../obj/Linux-x86-64-gfortran/dumpast/*.ast > ast.issues ./analyze_gfortran_warnings.py ../../obj/local_warn/psmp/*.warn > warn.issues ./analyze_src.py -b ../../ > src.issues - ./summarize_issues.py --suppressions=conventions.supp *.issues + ./summarize_issues.py --suppressions=conventions.supp ./*.issues fi diff --git a/tools/doxify/doxify.sh b/tools/doxify/doxify.sh index 47472839ff..718ef8fd9a 100755 --- a/tools/doxify/doxify.sh +++ b/tools/doxify/doxify.sh @@ -2,9 +2,8 @@ set -eo pipefail -ARGS=${ARGS:-} # Set to "-v" for debugging SCRIPTDIR=$( - cd $(dirname "$0") + cd "$(dirname "$0")" pwd ) # Pick up full path to scripts from wherever doxify.sh lives @@ -20,8 +19,8 @@ for file in "$@"; do # definitions that don't have any and checks that existing comments are complete, # fixing these if required. # * After adding comments, remove any double comment header lines - "${SCRIPTDIR}/fixcomments.pl" ${ARGS} "${file}" | - "${SCRIPTDIR}/remove_extra_comments.pl" ${ARGS} > "${tmp_file}" + "${SCRIPTDIR}/fixcomments.pl" "${file}" | + "${SCRIPTDIR}/remove_extra_comments.pl" > "${tmp_file}" # Copy the final modified source file on top of the original file if ! cmp -s "${file}" "${tmp_file}"; then diff --git a/tools/doxify/generate_doxygen.sh b/tools/doxify/generate_doxygen.sh index e68acd845e..a21dfb8f88 100755 --- a/tools/doxify/generate_doxygen.sh +++ b/tools/doxify/generate_doxygen.sh @@ -4,16 +4,16 @@ DOXYGENDIR="./doxygen" -for SRC_FN in $(find ./src/ -type f); do +while IFS= read -r -d '' SRC_FN; do echo "Preprocessing ${SRC_FN}" DEST_FN="${DOXYGENDIR}/${SRC_FN}" - mkdir -p $(dirname "${DEST_FN}") + mkdir -p "$(dirname "${DEST_FN}")" if [[ "${SRC_FN}" == *.F ]]; then ./tools/build_utils/fypp "${SRC_FN}" "${DEST_FN}" &> /dev/null else cp "${SRC_FN}" "${DEST_FN}" fi -done +done < <(find ./src/ -type f -print0) cp tools/logo/cp2k_logo_100.png ${DOXYGENDIR}/cp2k_logo.png @@ -26,6 +26,6 @@ doxygen ./Doxyfile # Remove CP2K from header bars because we already have the logo. cd html -sed -i 's/"projectname">CP2K/"projectname">/' *.html ./*/*.html ./*/*/*.html +sed -i 's/"projectname">CP2K/"projectname">/' ./*.html ./*/*.html ./*/*/*.html #EOF diff --git a/tools/formatting/test_formatting.sh b/tools/formatting/test_formatting.sh deleted file mode 100755 index 53fd06e366..0000000000 --- a/tools/formatting/test_formatting.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Test if prettify was run -# author: Ole Schuett - -set -e -rm -rf preprettify - -find ./src/ -type f -not -path "*/preprettify/*" -not -path "*/.git/*" -print0 | xargs -0 md5sum > checksums.md5 -md5sum ./data/POTENTIAL >> checksums.md5 - -make -j 16 pretty -make -j 16 pretty # run twice to ensure consistency with doxify - -cd data -cat GTH_POTENTIALS HF_POTENTIALS NLCC_POTENTIALS ALL_POTENTIALS > POTENTIAL -cd .. - -nfiles=$(wc -l checksums.md5 | cut -f 1 -d " ") -summary="Checked $nfiles files." -status="OK" - -echo "Searching for doxify warnings ..." -if grep -r -e "UNMATCHED_PROCEDURE_ARGUMENT" \ - -e "UNKNOWN_DOXYGEN_COMMENT" \ - -e "UNKNOWN_COMMENT" \ - --exclude-dir=".git" \ - --exclude-dir="preprettify" \ - ./src/*; then - summary="Found doxify warnings" - status="FAILED" -fi - -echo "Comparing MD5-sums ..." -if ! md5sum --quiet --check checksums.md5; then - summary='Code not invariant under "make pretty"' - status="FAILED" -fi - -rm checksums.md5 - -echo "Summary:" $summary -echo "Status:" $status - -#EOF diff --git a/tools/plan_mpi_omp/plan.sh b/tools/plan_mpi_omp/plan.sh index 0e58b703ea..e0fd6b45d9 100755 --- a/tools/plan_mpi_omp/plan.sh +++ b/tools/plan_mpi_omp/plan.sh @@ -34,7 +34,7 @@ if [ "" != "${HOME}" ]; then CONFIGFILE=${HOME}/.xconfigure-cp2k-plan else HERE=$( - cd $(dirname $0) + cd "$(dirname "$0")" || exit pwd -P ) CONFIGFILE=${HERE}/.xconfigure-cp2k-plan @@ -80,8 +80,8 @@ if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && fi OUTPUT=0 if [ "" = "$1" ]; then - if [ -e ${CONFIGFILE} ]; then # remind configuration - NCORESPERNODE=$(${CUT} -d" " -f1 ${CONFIGFILE}) + if [ -e "${CONFIGFILE}" ]; then # remind configuration + NCORESPERNODE=$(${CUT} -d" " -f1 "${CONFIGFILE}") elif [ "" != "${NC}" ]; then NCORESPERNODE=${NC} fi @@ -91,8 +91,8 @@ if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && shift fi if [ "" = "$1" ]; then - if [ -e ${CONFIGFILE} ]; then # remind configuration - NTHREADSPERCORE=$(${CUT} -d" " -f2 ${CONFIGFILE}) + if [ -e "${CONFIGFILE}" ]; then # remind configuration + NTHREADSPERCORE=$(${CUT} -d" " -f2 "${CONFIGFILE}") elif [ "" != "${HT}" ]; then NTHREADSPERCORE=${HT} fi @@ -102,8 +102,8 @@ if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && shift fi if [ "" = "$1" ]; then - if [ -e ${CONFIGFILE} ]; then # remind configuration - NPROCSPERNODE=$(${CUT} -d" " -f3 ${CONFIGFILE}) + if [ -e "${CONFIGFILE}" ]; then # remind configuration + NPROCSPERNODE=$(${CUT} -d" " -f3 "${CONFIGFILE}") elif [ "" != "${NS}" ]; then NPROCSPERNODE=${NS} fi @@ -128,7 +128,7 @@ if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && MIN_NRANKS=$((PENALTY_MIN * NPROCSPERNODE)) # remember system configuration if [ "0" != "${OUTPUT}" ]; then - echo "${NCORESPERNODE} ${NTHREADSPERCORE} ${NPROCSPERNODE}" > ${CONFIGFILE} 2> /dev/null + echo "${NCORESPERNODE} ${NTHREADSPERCORE} ${NPROCSPERNODE}" > "${CONFIGFILE}" 2> /dev/null fi NCORESTOTAL=$((TOTALNUMNODES * NCORESPERNODE)) NCORESOCKET=$((NCORESPERNODE / NPROCSPERNODE)) @@ -138,7 +138,7 @@ if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && NRANKSMIN=$((TOTALNUMNODES * NPROCSPERNODE)) NSQRT_MIN=$(isqrt ${NRANKSMIN}) NSQRT_MAX=$(isqrt ${NCORESTOTAL}) - for NSQRT in $(${SEQ} ${NSQRT_MIN} ${NSQRT_MAX}); do + for NSQRT in $(${SEQ} "${NSQRT_MIN}" "${NSQRT_MAX}"); do NSQR=$((NSQRT * NSQRT)) NRANKSPERNODE=$((NSQR / TOTALNUMNODES)) if [ "${NSQR}" = "$((TOTALNUMNODES * NRANKSPERNODE))" ]; then @@ -191,8 +191,8 @@ if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && NRANKSPERNODE=$(echo "${RESULT}" | ${CUT} -d";" -f1) NTHREADSPERRANK=$((NTHREADSPERNODE / NRANKSPERNODE)) PENALTY=$(echo "${RESULT}" | ${CUT} -d";" -f2) - if [ "0" != "$((OUTPUT_SQR < OUTPUT_POT))" ] || - [ "0" != "$((PENALTY <= PENALTY_TOP))" ]; then + if [ "$((OUTPUT_SQR < OUTPUT_POT))" != "0" ] || + [ "$((PENALTY <= PENALTY_TOP))" != "0" ]; then NSQRT=$(echo "${RESULT}" | ${CUT} -d";" -f3) echo "[${NRANKSPERNODE}x${NTHREADSPERRANK}]: ${NRANKSPERNODE} ranks per node with ${NTHREADSPERRANK} thread(s) per rank (${PENALTY}% penalty) -> ${NSQRT}x${NSQRT}" OUTPUT_SQR=$((OUTPUT_SQR + 1)) @@ -201,7 +201,7 @@ if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && if [ "0" != "${OUTPUT_SQR}" ]; then echo "--------------------------------------------------------------------------------" fi - for NRANKSPERNODE in $(${SEQ} ${MIN_NRANKS} ${NCORESPERNODE}); do + for NRANKSPERNODE in $(${SEQ} "${MIN_NRANKS}" "${NCORESPERNODE}"); do REST=$((NCORESPERNODE % NRANKSPERNODE)) PENALTY=$(((100 * REST + NCORESPERNODE - 1) / NCORESPERNODE)) # criterion to add penalty in case of unbalanced load diff --git a/tools/precommit/deploy.sh b/tools/precommit/deploy.sh old mode 100755 new mode 100644 index 0b4442daa2..2a7fc25087 --- a/tools/precommit/deploy.sh +++ b/tools/precommit/deploy.sh @@ -7,12 +7,12 @@ set -x SHORT_SHA=$(git rev-parse --short HEAD) docker build --build-arg "REVISION=${SHORT_SHA}" -t cp2k-precommit . -docker tag cp2k-precommit gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA} -docker tag cp2k-precommit gcr.io/cp2k-org-project/img_cp2kprecommit:latest -docker push gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA} -docker push gcr.io/cp2k-org-project/img_cp2kprecommit:latest +docker tag "cp2k-precommit gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA}" +docker tag "cp2k-precommit gcr.io/cp2k-org-project/img_cp2kprecommit:latest" +docker push "gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA}" +docker push "gcr.io/cp2k-org-project/img_cp2kprecommit:latest" gcloud run deploy cp2k-precommit --platform=managed --region=us-central1 \ - --image=gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA} + --image="gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA}" #EOF