From ee4ed5d94256fc9ee3bc726bdaddc6622014d21b Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 17 Jun 2018 20:42:36 +0100 Subject: [PATCH] wmake: Correct issues introduced during updates for shellcheck Patch contributed by Bruno Santos Resolves bug-report https://bugs.openfoam.org/view.php?id=2983 --- wmake/wclean | 2 +- wmake/wdep | 2 +- wmake/wmake | 6 +++--- wmake/wrmdep | 49 +++++++++++++++++++++++++++++++++++++++---------- wmake/wrmo | 2 +- 5 files changed, 45 insertions(+), 16 deletions(-) diff --git a/wmake/wclean b/wmake/wclean index f8d475a334..9a963605fb 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -38,7 +38,7 @@ Script=${0##*/} # Source the wmake functions # shellcheck source=scripts/wmakeFunctions -. ${0%/*}/scripts/wmakeFunctions +. "${0%/*}/scripts/wmakeFunctions" error() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done diff --git a/wmake/wdep b/wmake/wdep index 64db3f6234..6dd0ad27b5 100755 --- a/wmake/wdep +++ b/wmake/wdep @@ -39,7 +39,7 @@ Script=${0##*/} # Source the wmake functions # shellcheck source=scripts/wmakeFunctions -. ${0%/*}/scripts/wmakeFunctions +. "${0%/*}/scripts/wmakeFunctions" usage() { cat< /dev/null 2>&1 \ + [ $# -ge 2 ] && [ "$2" -gt 0 ] > /dev/null 2>&1 \ && shift && export WM_NCOMPPROCS=$1 echo "Compiling enabled on $WM_NCOMPPROCS cores" ;; @@ -222,11 +222,11 @@ then WM_NCOMPPROCS=$(wmakeScheduler -count) || unset WM_NCOMPPROCS fi -if [ "$WM_NCOMPPROCS" ] +if [ -n "$WM_NCOMPPROCS" ] then parOpt="-j $WM_NCOMPPROCS" - if [ "$WM_NCOMPPROCS" -gt 1 ] && [ ! "$MAKEFLAGS" ] + if [ "$WM_NCOMPPROCS" -gt 1 ] && [ -z "$MAKEFLAGS" ] then lockDir=$HOME/.$WM_PROJECT/.wmake diff --git a/wmake/wrmdep b/wmake/wrmdep index 644fab0848..b2a9ecd663 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -55,7 +55,7 @@ Script=${0##*/} # Source the wmake functions # shellcheck source=scripts/wmakeFunctions -. ${0%/*}/scripts/wmakeFunctions +. "${0%/*}/scripts/wmakeFunctions" usage() { cat</dev/null + elif [ "$#" -eq 2 ] + then + find "$1" -name '*.dep' -exec grep -q "$2" '{}' \; \ + -exec rm '{}' \; -print + fi +} + #------------------------------------------------------------------------------ # Parse arguments and options #------------------------------------------------------------------------------ @@ -144,20 +156,37 @@ files) findObjectDir . - # With the -a/-all option replace the current platform with a wildcard - if [ "$all" = "all" ] - then - objectsDir=$(echo "$objectsDir" | sed s%"$WM_OPTIONS"%*% ) - fi - + # First give the verbose information for the current searching method if [ "$#" -eq 0 ] then echo "removing all .dep files ..." - find "$objectsDir" -name '*.dep' -print0 | xargs -0t rm 2>/dev/null else echo "removing .dep files referring to $1 ..." - find "$objectsDir" -name '*.dep' -exec grep -q "$1" '{}' \; \ - -exec rm '{}' \; -print + fi + + # With the -a/-all option replace the current platform with a wildcard + if [ "$all" = "all" ] + then + + # Handle the removal on all platforms for consistency + mainPath=${objectsDir%%/$WM_OPTIONS*} + objSubPath=${objectsDir##*$WM_OPTIONS/} + + for pathEntry in "$mainPath"/* + do + if [ -e "$pathEntry/$objSubPath" ] + then + # Note: + # If $1 is empty, it should still work for the default method + removeDepFiles "$pathEntry/$objSubPath" "$1" + fi + done + + else + + # Handle only the removal for the current WM_OPTIONS + removeDepFiles "$objectsDir" "$1" + fi ;; diff --git a/wmake/wrmo b/wmake/wrmo index a0fe20bd03..9adb8ab0dc 100755 --- a/wmake/wrmo +++ b/wmake/wrmo @@ -39,7 +39,7 @@ Script=${0##*/} # Source the wmake functions # shellcheck source=scripts/wmakeFunctions -. ${0%/*}/scripts/wmakeFunctions +. "${0%/*}/scripts/wmakeFunctions" usage() { cat<