From 1b0a93c7c97aafab500bf77bf937d7ca8e8012a7 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Fri, 19 Jun 2020 13:12:57 +0200
Subject: [PATCH] STYLE: update syntax of tutorial scripts

---
 tutorials/Allclean                           |  7 +-
 tutorials/Allcollect                         |  9 +++
 tutorials/Allrun                             | 77 ++------------------
 tutorials/deposition/Allclean                |  5 +-
 tutorials/deposition/Allrun                  |  5 +-
 tutorials/deposition/Allrun-parallel         |  5 +-
 tutorials/entrainment/Allclean               |  5 +-
 tutorials/entrainment/Allrun                 |  5 +-
 tutorials/entrainment/Allrun-parallel        |  5 +-
 tutorials/gridToSTL/Allclean                 |  5 +-
 tutorials/gridToSTL/Allrun                   |  5 +-
 tutorials/montereycanyon/Allclean            |  4 +-
 tutorials/montereycanyon/Allrun              |  4 +-
 tutorials/montereycanyon/Allrun-parallel     |  5 +-
 tutorials/releaseAreaMapping/Allclean        |  5 +-
 tutorials/releaseAreaMapping/Allrun          |  5 +-
 tutorials/releaseAreaMapping/Allrun-parallel |  7 +-
 tutorials/simpleslope/Allclean               |  5 +-
 tutorials/simpleslope/Allrun                 |  5 +-
 tutorials/simpleslope/Allrun-parallel        |  5 +-
 tutorials/wolfsgrube/Allclean                |  5 +-
 tutorials/wolfsgrube/Allrun-parallel         |  5 +-
 tutorials/wolfsgrube/Allrun-redistribute     |  5 +-
 tutorials/wolfsgrube/Allrun-serial           |  5 +-
 24 files changed, 79 insertions(+), 119 deletions(-)
 create mode 100755 tutorials/Allcollect

diff --git a/tutorials/Allclean b/tutorials/Allclean
index 40e6631..b6eda3e 100755
--- a/tutorials/Allclean
+++ b/tutorials/Allclean
@@ -1,12 +1,13 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/LogFunctions    # Tutorial log-file functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions    # Tutorial logfile functions
+#------------------------------------------------------------------------------
 
 echo "--------"
 removeLogs
 
 echo "Cleaning tutorials"
-foamCleanTutorials cases
+foamCleanTutorials -self
 
 echo "--------"
 
diff --git a/tutorials/Allcollect b/tutorials/Allcollect
new file mode 100755
index 0000000..745ab29
--- /dev/null
+++ b/tutorials/Allcollect
@@ -0,0 +1,9 @@
+#!/bin/sh
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions    # Tutorial log-file functions
+#------------------------------------------------------------------------------
+
+# Collect log files as 'testLoopReport'
+collectLogs
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/Allrun b/tutorials/Allrun
index 34a467a..5ce3344 100755
--- a/tutorials/Allrun
+++ b/tutorials/Allrun
@@ -1,79 +1,12 @@
 #!/bin/sh
+cd "${0%/*}" || exit                            # Run from this directory
+## . ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions    # Tutorial logfile functions
 #------------------------------------------------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | www.openfoam.com
-#    \\/     M anipulation  |
-#------------------------------------------------------------------------------
-#     Copyright (C) 2017 OpenCFD Ltd.
-#------------------------------------------------------------------------------
-# License
-#     This file is part of OpenFOAM, licensed under GNU General Public License
-#     <http://www.gnu.org/licenses/>.
-#
-# Script
-#     Allrun
-#
-# Description
-#     Run tutorial cases and summarize the outcome as 'testLoopReport'
-#
-#------------------------------------------------------------------------------
-cd ${0%/*} || exit 1    # Run from this directory
-
-usage()
-{
-    exec 1>&2
-    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
-    cat<<USAGE
-
-usage: ${0##*/} [OPTION]
-
-options:
-  -collect          Collect logs only. Can be useful for aborted runs.
-  -help             print the usage
-
-Run tutorial cases and summarize the outcome as 'testLoopReport'
 
-USAGE
-    exit 1
-}
-
-#------------------------------------------------------------------------------
-unset optCollectOnly
-
-# Parse options
-while [ "$#" -gt 0 ]
-do
-    case "$1" in
-    -h | -help)
-        usage
-        ;;
-    -collect)
-        optCollectOnly=true
-        ;;
-    -test)   # Known options that should be passed through
-        break
-        ;;
-    -*)
-        usage "unknown option: $1"
-        ;;
-    *)
-        break
-        ;;
-    esac
-    shift
-done
-
-
-#------------------------------------------------------------------------------
-. $WM_PROJECT_DIR/bin/tools/LogFunctions    # Tutorial log-file functions
+# Any tests...
 
-if [ -z "$optCollectOnly" ]
-then
-    foamRunTutorials -skipFirst $*          # Run tutorials recursively
-fi
+foamRunTutorials -skipFirst $*          # Run tutorials recursively
 
-collectLogs
+## collectLogs
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/deposition/Allclean b/tutorials/deposition/Allclean
index 15d1444..c82445d 100755
--- a/tutorials/deposition/Allclean
+++ b/tutorials/deposition/Allclean
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions  # Tutorial clean functions
+#------------------------------------------------------------------------------
 
 cleanCase0
 cleanFaMesh
diff --git a/tutorials/deposition/Allrun b/tutorials/deposition/Allrun
index 340532d..feab2e2 100755
--- a/tutorials/deposition/Allrun
+++ b/tutorials/deposition/Allrun
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication slopeMesh
 
diff --git a/tutorials/deposition/Allrun-parallel b/tutorials/deposition/Allrun-parallel
index ac08a11..dd7fe45 100755
--- a/tutorials/deposition/Allrun-parallel
+++ b/tutorials/deposition/Allrun-parallel
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication slopeMesh
 
diff --git a/tutorials/entrainment/Allclean b/tutorials/entrainment/Allclean
index 15d1444..c82445d 100755
--- a/tutorials/entrainment/Allclean
+++ b/tutorials/entrainment/Allclean
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions  # Tutorial clean functions
+#------------------------------------------------------------------------------
 
 cleanCase0
 cleanFaMesh
diff --git a/tutorials/entrainment/Allrun b/tutorials/entrainment/Allrun
index 340532d..feab2e2 100755
--- a/tutorials/entrainment/Allrun
+++ b/tutorials/entrainment/Allrun
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication slopeMesh
 
diff --git a/tutorials/entrainment/Allrun-parallel b/tutorials/entrainment/Allrun-parallel
index ac08a11..dd7fe45 100755
--- a/tutorials/entrainment/Allrun-parallel
+++ b/tutorials/entrainment/Allrun-parallel
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication slopeMesh
 
diff --git a/tutorials/gridToSTL/Allclean b/tutorials/gridToSTL/Allclean
index 1dbd0f8..5b22a83 100755
--- a/tutorials/gridToSTL/Allclean
+++ b/tutorials/gridToSTL/Allclean
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions  # Tutorial clean functions
+#------------------------------------------------------------------------------
 
 rm -rf constant/surface.stl
 cleanCase0
diff --git a/tutorials/gridToSTL/Allrun b/tutorials/gridToSTL/Allrun
index e5e4127..58f15aa 100755
--- a/tutorials/gridToSTL/Allrun
+++ b/tutorials/gridToSTL/Allrun
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication gridToSTL
 
diff --git a/tutorials/montereycanyon/Allclean b/tutorials/montereycanyon/Allclean
index ffc3162..b0278bc 100755
--- a/tutorials/montereycanyon/Allclean
+++ b/tutorials/montereycanyon/Allclean
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd "${0%/*}" || exit                                # Run from this directory
-. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions      # Tutorial clean functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions  # Tutorial clean functions
 #------------------------------------------------------------------------------
 
 rm -rf constant/surface.stl
diff --git a/tutorials/montereycanyon/Allrun b/tutorials/montereycanyon/Allrun
index 5a92dc4..51deb33 100755
--- a/tutorials/montereycanyon/Allrun
+++ b/tutorials/montereycanyon/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd "${0%/*}" || exit                                # Run from this directory
-. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions        # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
 #------------------------------------------------------------------------------
 
 runApplication gridToSTL
diff --git a/tutorials/montereycanyon/Allrun-parallel b/tutorials/montereycanyon/Allrun-parallel
index 77ca247..8dc14b9 100755
--- a/tutorials/montereycanyon/Allrun-parallel
+++ b/tutorials/montereycanyon/Allrun-parallel
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd "${0%/*}" || exit                                # Run from this directory
-. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions        # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
 #------------------------------------------------------------------------------
 
 runApplication gridToSTL
@@ -17,5 +17,4 @@ runParallel $(getApplication)
 
 runApplication reconstructPar
 
-
 #------------------------------------------------------------------------------
diff --git a/tutorials/releaseAreaMapping/Allclean b/tutorials/releaseAreaMapping/Allclean
index 15d1444..c82445d 100755
--- a/tutorials/releaseAreaMapping/Allclean
+++ b/tutorials/releaseAreaMapping/Allclean
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions  # Tutorial clean functions
+#------------------------------------------------------------------------------
 
 cleanCase0
 cleanFaMesh
diff --git a/tutorials/releaseAreaMapping/Allrun b/tutorials/releaseAreaMapping/Allrun
index ca4aa78..a07c19f 100755
--- a/tutorials/releaseAreaMapping/Allrun
+++ b/tutorials/releaseAreaMapping/Allrun
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication blockMesh
 
diff --git a/tutorials/releaseAreaMapping/Allrun-parallel b/tutorials/releaseAreaMapping/Allrun-parallel
index 1db2c36..a8229cd 100755
--- a/tutorials/releaseAreaMapping/Allrun-parallel
+++ b/tutorials/releaseAreaMapping/Allrun-parallel
@@ -1,8 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
-runApplication blockMesh 
+runApplication blockMesh
 
 runApplication makeFaMesh
 
diff --git a/tutorials/simpleslope/Allclean b/tutorials/simpleslope/Allclean
index 15d1444..c82445d 100755
--- a/tutorials/simpleslope/Allclean
+++ b/tutorials/simpleslope/Allclean
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions  # Tutorial clean functions
+#------------------------------------------------------------------------------
 
 cleanCase0
 cleanFaMesh
diff --git a/tutorials/simpleslope/Allrun b/tutorials/simpleslope/Allrun
index 340532d..feab2e2 100755
--- a/tutorials/simpleslope/Allrun
+++ b/tutorials/simpleslope/Allrun
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication slopeMesh
 
diff --git a/tutorials/simpleslope/Allrun-parallel b/tutorials/simpleslope/Allrun-parallel
index ac08a11..dd7fe45 100755
--- a/tutorials/simpleslope/Allrun-parallel
+++ b/tutorials/simpleslope/Allrun-parallel
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication slopeMesh
 
diff --git a/tutorials/wolfsgrube/Allclean b/tutorials/wolfsgrube/Allclean
index 1dbd0f8..5b22a83 100755
--- a/tutorials/wolfsgrube/Allclean
+++ b/tutorials/wolfsgrube/Allclean
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions  # Tutorial clean functions
+#------------------------------------------------------------------------------
 
 rm -rf constant/surface.stl
 cleanCase0
diff --git a/tutorials/wolfsgrube/Allrun-parallel b/tutorials/wolfsgrube/Allrun-parallel
index 694e28f..9840a2c 100755
--- a/tutorials/wolfsgrube/Allrun-parallel
+++ b/tutorials/wolfsgrube/Allrun-parallel
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication gridToSTL
 
diff --git a/tutorials/wolfsgrube/Allrun-redistribute b/tutorials/wolfsgrube/Allrun-redistribute
index 6d39bdb..a17e137 100755
--- a/tutorials/wolfsgrube/Allrun-redistribute
+++ b/tutorials/wolfsgrube/Allrun-redistribute
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication gridToSTL
 
diff --git a/tutorials/wolfsgrube/Allrun-serial b/tutorials/wolfsgrube/Allrun-serial
index 31a1e4d..9619f6a 100755
--- a/tutorials/wolfsgrube/Allrun-serial
+++ b/tutorials/wolfsgrube/Allrun-serial
@@ -1,6 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                        # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+cd "${0%/*}" || exit                            # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions    # Tutorial run functions
+#------------------------------------------------------------------------------
 
 runApplication gridToSTL
 
-- 
GitLab