diff --git a/Allwmake b/Allwmake
index 240e7e262163cea8812951bc487a842857f1b561..6136570be0653026b149d645eb3047dfe31b4542 100755
--- a/Allwmake
+++ b/Allwmake
@@ -80,18 +80,6 @@ then
     echo
 elif [ -d "$WM_PROJECT_DIR/modules" ]
 then
-    echo "========================================"
-    echo "Compile OpenFOAM modules"
-    echo "    ignoring possible compilation errors"
-    echo "    make certain to check the output file"
-    echo
-    set +e
-    export WM_CONTINUE_ON_ERROR=true
-
-    # Default build into OpenFOAM project locations
-    : "${FOAM_MODULE_PREFIX:=${FOAM_LIBBIN%/*}}"
-    export FOAM_MODULE_PREFIX
-
     (cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all)
 fi
 
diff --git a/modules/Allwmake b/modules/Allwmake
index 1a6ca9486759c29330e101a1422bacb610364fe5..b6bf9301a57aebc8c30a5b756597596f679f2a88 100755
--- a/modules/Allwmake
+++ b/modules/Allwmake
@@ -7,9 +7,22 @@ targetType=libso
 # Default build into OpenFOAM project locations unless specified with
 # -prefix or FOAM_MODULE_PREFIX env varable
 
-: "${FOAM_MODULE_PREFIX:=${FOAM_LIBBIN%/*}}"
+# Long form to avoid dash 0.5.8 error (issue #1757)
+[ -n "$FOAM_MODULE_PREFIX" ] || FOAM_MODULE_PREFIX="${FOAM_LIBBIN%/*}"
 export FOAM_MODULE_PREFIX
 
+echo "========================================"
+echo "Compile OpenFOAM modules"
+echo "prefix = $FOAM_MODULE_PREFIX"
+echo
+echo "    ignoring possible compilation errors"
+echo "    make certain to check the output file"
+echo
+set +e
+export WM_CONTINUE_ON_ERROR=true
+
+#------------------------------------------------------------------------------
+
 for moduleName in $(./list-modules)
 do
     if [ -d "$moduleName" ]