From 6afa62a6e418b07fd4c1b42a22669a8fcb532085 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 7 Jul 2017 16:00:57 +0200 Subject: [PATCH] STYLE: use shell 'command' instead of 'which' in tutorials --- .../chemFoam/gri/validation/createGraph | 7 +++---- .../chemFoam/h2/validation/createGraph | 8 ++++---- .../chemFoam/ic8h18/validation/createGraph | 8 ++++---- .../chemFoam/ic8h18_TDAC/validation/createGraph | 8 ++++---- .../chemFoam/nc7h16/validation/createGraph | 8 ++++---- .../LES/compartmentFire/validation/createGraphs | 9 ++++----- .../buoyantCavity/validation/createGraphs | 16 +++++++--------- .../jouleHeatingSolid/createGraphs | 17 +++++++---------- .../boundaryWallFunctionsProfile/Allrun | 9 ++++----- .../planarPoiseuille/validation/createGraph | 8 ++++---- .../simpleFoam/T3A/validation/createGraphs | 8 ++++---- 11 files changed, 49 insertions(+), 57 deletions(-) diff --git a/tutorials/combustion/chemFoam/gri/validation/createGraph b/tutorials/combustion/chemFoam/gri/validation/createGraph index d0fb9cc013..1ef428f28d 100755 --- a/tutorials/combustion/chemFoam/gri/validation/createGraph +++ b/tutorials/combustion/chemFoam/gri/validation/createGraph @@ -1,10 +1,9 @@ #!/bin/sh -if ! which gnuplot > /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} gnuplot< /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} gnuplot< /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} gnuplot< /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} gnuplot< /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} gnuplot< /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} SETSDIRT="../postProcessing/thermoCouple" diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs index 693c8dbfdf..7016a3610a 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs +++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs @@ -85,20 +85,18 @@ EOF echo "createGraphs:" -# test if gnuplot exists on the system -if ! which gnuplot > /dev/null 2>&1 -then - echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} SETSDIR="../postProcessing/sample" -if [ ! -d $SETSDIR ] -then - echo "FOAM FATAL ERROR: result sets not available in directory $SETSDIR" >&2 +[ -d "$SETSDIR" ] || { + echo "FOAM FATAL ERROR: result sets not available in directory $SETSDIR" 1>&2 exit 1 -fi +} # paths to data LATESTTIME=$(ls $SETSDIR) diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs index 04bbc57ea0..1c39ff49a9 100755 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs @@ -30,28 +30,25 @@ # Joule heating case # #------------------------------------------------------------------------------ - cd ${0%/*} || exit 1 # Run from this directory # Stop on first error set -e -# test if gnuplot exists on the system -if ! which gnuplot > /dev/null 2>&1 -then - echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} echo "Creating graph" OFDATA='postProcessing/sample1/solid/20000/centreLine_T_jouleHeatingSource:V_jouleHeatingSource:sigma.xy' -if [ ! -f "$OFDATA" ] -then - echo "FOAM FATAL ERROR: OpenFOAM results not available in $OFDATA" >&2 +[ -f "$OFDATA" ] || { + echo "FOAM FATAL ERROR: OpenFOAM results not available in $OFDATA" 1>&2 exit 1 -fi +} gnuplot< /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} graphName="OF_vs_ANALYTICAL.eps" diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph index a30402600e..d6402c1b4d 100755 --- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph +++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph @@ -3,11 +3,11 @@ tail -n +4 ../postProcessing/probes/0/U | \ tr -s " " | tr -d '(' | cut -d " " -f2-3 > ../Numerical.dat -if ! which gnuplot > /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} gnuplot< /dev/null 2>&1 -then - echo "gnuplot not found - skipping graph creation" >&2 +# Test if gnuplot exists on the system +command -v gnuplot >/dev/null 2>&1 || { + echo "gnuplot not found - skipping graph creation" 1>&2 exit 1 -fi +} gnuplot<