From 7051abc371ae11698eb7f30b95ccde6b77d0662d Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Tue, 4 Aug 2020 15:02:51 +0200
Subject: [PATCH] TUT: fix run/clean scripts syntax

---
 .../sensitivityMaps/sbend/laminar/Allclean    |  4 ++-
 .../laminar/contactAngleCavity/Allclean       |  2 +-
 .../mixerVesselAMI2D-topologyChange/Allrun    |  5 +--
 .../mixerVesselAMI2D-topologyChange/makeMesh  |  5 +--
 .../mesh/refineMesh/refineFieldDirs/Allrun    | 36 +++++++++----------
 .../laminar/sloshingTank2D/Allclean           |  1 +
 .../laminar/depthCharge2D/Allclean            |  8 +++--
 .../laminar/depthCharge2D/Allrun              |  5 +--
 .../laminar/depthCharge3D/Allclean            |  6 ++--
 .../laminar/depthCharge3D/Allrun              |  5 +--
 10 files changed, 44 insertions(+), 33 deletions(-)

diff --git a/tutorials/incompressible/adjointOptimisationFoam/sensitivityMaps/sbend/laminar/Allclean b/tutorials/incompressible/adjointOptimisationFoam/sensitivityMaps/sbend/laminar/Allclean
index 61816694dbe..52a7c1663cb 100755
--- a/tutorials/incompressible/adjointOptimisationFoam/sensitivityMaps/sbend/laminar/Allclean
+++ b/tutorials/incompressible/adjointOptimisationFoam/sensitivityMaps/sbend/laminar/Allclean
@@ -4,5 +4,7 @@ cd "${0%/*}" || exit                                # Run from this directory
 #------------------------------------------------------------------------------
 
 cleanCase
-rm 0/*.gz
+
+rm -f 0/*.gz
+
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleFoam/laminar/contactAngleCavity/Allclean b/tutorials/incompressible/pimpleFoam/laminar/contactAngleCavity/Allclean
index 43b1e567b1d..a7e5dc4a813 100755
--- a/tutorials/incompressible/pimpleFoam/laminar/contactAngleCavity/Allclean
+++ b/tutorials/incompressible/pimpleFoam/laminar/contactAngleCavity/Allclean
@@ -1,5 +1,5 @@
 #!/bin/sh
-cd ${0%/*} || exit                                  # Run from this directory
+cd "${0%/*}" || exit                                # Run from this directory
 . ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions      # Tutorial clean functions
 #------------------------------------------------------------------------------
 
diff --git a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/Allrun b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/Allrun
index 0cae8060837..3aaff9382e8 100755
--- a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/Allrun
+++ b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/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
+#------------------------------------------------------------------------------
 
 ./makeMesh
 
diff --git a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/makeMesh b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/makeMesh
index fc56e7be3ce..5a991c3d4f8 100755
--- a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/makeMesh
+++ b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange/makeMesh
@@ -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
+#------------------------------------------------------------------------------
 
 m4 < system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/mesh/refineMesh/refineFieldDirs/Allrun b/tutorials/mesh/refineMesh/refineFieldDirs/Allrun
index 7909fb899c5..ca48dae90a0 100755
--- a/tutorials/mesh/refineMesh/refineFieldDirs/Allrun
+++ b/tutorials/mesh/refineMesh/refineFieldDirs/Allrun
@@ -14,45 +14,45 @@ wclean calcRadiusField
 
 runApplication blockMesh
 
-##### Procedure for special refinement over Z
-
 # We need the 0 folder to exist for these steps
 mkdir 0
 
 # Refine over Z, in 6 passes
 for index in 1 2 3 4 5 6
 do
+    suffix="tier$index"
 
-  runApplication -s tier$index  calcRadiusField
-
-  runApplication -s tier$index \
-      topoSet -dict system/topoSetDict.tier$index
+    runApplication -s "$suffix" calcRadiusField
 
-  ## foamToVTK -cellSet tier$index
+    runApplication -s "$suffix" \
+        topoSet -dict system/topoSetDict.tier$index
 
-  runApplication -s tier$index \
-      refineMesh -dict system/refineMeshDict.tier$index -overwrite
+    ## foamToVTK -cellSet "$suffix"
 
-  rm -r 0/*
+    runApplication -s "$suffix" \
+        refineMesh -dict system/refineMeshDict."$suffix" -overwrite
 
+    rm -r 0/*
 done
 
 # Refine over cylindrical coordinates, in 3 passes
 for index in 1 2 3
 do
+    suffix="range$index"
 
-  runApplication -s range$index  calcRadiusField -calcDirections
+    runApplication -s "$suffix" calcRadiusField -calcDirections
 
-  runApplication -s range$index \
-      topoSet -dict system/topoSetDict.range$index
+    runApplication -s "$suffix" \
+        topoSet -dict system/topoSetDict."$suffix"
 
-  ## foamToVTK -cellSet tier$index
+    ## foamToVTK -cellSet "$suffix"
 
-  runApplication -s range$index \
-      refineMesh -dict system/refineMeshDict.range$index -overwrite
-
-  rm -r 0/*
+    runApplication -s "$suffix" \
+        refineMesh -dict system/refineMeshDict."$suffix" -overwrite
 
+    rm -r 0/*
 done
 
+rmdir 0 2>/dev/null
+
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allclean b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allclean
index 8dfb6f7ba60..fb1f3847301 100755
--- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allclean
+++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allclean
@@ -1,5 +1,6 @@
 #!/bin/sh
 cd "${0%/*}" || exit                                # Run from this directory
+. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions      # Tutorial clean functions
 #------------------------------------------------------------------------------
 
 cleanCase0
diff --git a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/Allclean b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/Allclean
index 188f107b0e9..faeb44ab753 100755
--- a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/Allclean
+++ b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/Allclean
@@ -1,8 +1,10 @@
 #!/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
-rm -r sequencedVTK
+
+rm -rf sequencedVTK
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/Allrun b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/Allrun
index 98b1a954b19..30fed9690ed 100755
--- a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/Allrun
+++ b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge2D/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
 restore0Dir
diff --git a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/Allclean b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/Allclean
index 3b8c6e8e2fb..a3ef4042a2c 100755
--- a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/Allclean
+++ b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/Allclean
@@ -1,8 +1,10 @@
 #!/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
+
 rm -rf processor*
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/Allrun b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/Allrun
index bdb96428fab..02b2d981f37 100755
--- a/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/Allrun
+++ b/tutorials/multiphase/compressibleInterIsoFoam/laminar/depthCharge3D/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
 restore0Dir
-- 
GitLab