STYLE: use shell 'command' instead of 'which' in tutorials

This commit is contained in:
Mark Olesen
2017-07-07 16:00:57 +02:00
parent e7da4f0d07
commit 6afa62a6e4
11 changed files with 49 additions and 57 deletions

View File

@ -1,10 +1,9 @@
#!/bin/sh #!/bin/sh
if ! which gnuplot > /dev/null 2>&1 command -v gnuplot >/dev/null 2>&1 || {
then echo "gnuplot not found - skipping graph creation" 1>&2
echo "gnuplot not found - skipping graph creation" >&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set terminal postscript eps color enhanced "Helveicta,20" set terminal postscript eps color enhanced "Helveicta,20"

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
if ! which gnuplot > /dev/null 2>&1 # Test if gnuplot exists on the system
then command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" >&2 echo "gnuplot not found - skipping graph creation" 1>&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set terminal postscript eps color enhanced "Helvetica,20" set terminal postscript eps color enhanced "Helvetica,20"

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
if ! which gnuplot > /dev/null 2>&1 # Test if gnuplot exists on the system
then command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" >&2 echo "gnuplot not found - skipping graph creation" 1>&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set terminal postscript eps color enhanced "Helvetica,20" set terminal postscript eps color enhanced "Helvetica,20"

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
if ! which gnuplot > /dev/null 2>&1 # Test if gnuplot exists on the system
then command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" >&2 echo "gnuplot not found - skipping graph creation" 1>&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set terminal postscript eps color enhanced "Helvetica,20" set terminal postscript eps color enhanced "Helvetica,20"

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
if ! which gnuplot > /dev/null 2>&1 # Test if gnuplot exists on the system
then command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" >&2 echo "gnuplot not found - skipping graph creation" 1>&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set terminal postscript eps color enhanced "Helvetica,20" set terminal postscript eps color enhanced "Helvetica,20"

View File

@ -53,12 +53,11 @@ EOF
} }
# test if gnuplot exists on the system # Test if gnuplot exists on the system
if ! which gnuplot > /dev/null 2>&1 command -v gnuplot >/dev/null 2>&1 || {
then echo "gnuplot not found - skipping graph creation" 1>&2
echo "gnuplot not found - skipping graph creation" >&2
exit 1 exit 1
fi }
SETSDIRT="../postProcessing/thermoCouple" SETSDIRT="../postProcessing/thermoCouple"

View File

@ -85,20 +85,18 @@ EOF
echo "createGraphs:" echo "createGraphs:"
# test if gnuplot exists on the system # Test if gnuplot exists on the system
if ! which gnuplot > /dev/null 2>&1 command -v gnuplot >/dev/null 2>&1 || {
then echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" 1>&2
echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" >&2
exit 1 exit 1
fi }
SETSDIR="../postProcessing/sample" SETSDIR="../postProcessing/sample"
if [ ! -d $SETSDIR ] [ -d "$SETSDIR" ] || {
then echo "FOAM FATAL ERROR: result sets not available in directory $SETSDIR" 1>&2
echo "FOAM FATAL ERROR: result sets not available in directory $SETSDIR" >&2
exit 1 exit 1
fi }
# paths to data # paths to data
LATESTTIME=$(ls $SETSDIR) LATESTTIME=$(ls $SETSDIR)

View File

@ -30,28 +30,25 @@
# Joule heating case # Joule heating case
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
# Stop on first error # Stop on first error
set -e set -e
# test if gnuplot exists on the system # Test if gnuplot exists on the system
if ! which gnuplot > /dev/null 2>&1 command -v gnuplot >/dev/null 2>&1 || {
then echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" 1>&2
echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" >&2
exit 1 exit 1
fi }
echo "Creating graph" echo "Creating graph"
OFDATA='postProcessing/sample1/solid/20000/centreLine_T_jouleHeatingSource:V_jouleHeatingSource:sigma.xy' OFDATA='postProcessing/sample1/solid/20000/centreLine_T_jouleHeatingSource:V_jouleHeatingSource:sigma.xy'
if [ ! -f "$OFDATA" ] [ -f "$OFDATA" ] || {
then echo "FOAM FATAL ERROR: OpenFOAM results not available in $OFDATA" 1>&2
echo "FOAM FATAL ERROR: OpenFOAM results not available in $OFDATA" >&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set terminal postscript eps color enhanced set terminal postscript eps color enhanced

View File

@ -36,12 +36,11 @@ done
# create validation plot # create validation plot
# test if gnuplot exists on the system # Test if gnuplot exists on the system
if ! which gnuplot > /dev/null 2>&1 command -v gnuplot >/dev/null 2>&1 || {
then echo "gnuplot not found - skipping graph creation" 1>&2
echo "gnuplot not found - skipping graph creation" >&2
exit 1 exit 1
fi }
graphName="OF_vs_ANALYTICAL.eps" graphName="OF_vs_ANALYTICAL.eps"

View File

@ -3,11 +3,11 @@
tail -n +4 ../postProcessing/probes/0/U | \ tail -n +4 ../postProcessing/probes/0/U | \
tr -s " " | tr -d '(' | cut -d " " -f2-3 > ../Numerical.dat tr -s " " | tr -d '(' | cut -d " " -f2-3 > ../Numerical.dat
if ! which gnuplot > /dev/null 2>&1 # Test if gnuplot exists on the system
then command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" >&2 echo "gnuplot not found - skipping graph creation" 1>&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set terminal postscript eps color enhanced "Helvetica,20" set terminal postscript eps color enhanced "Helvetica,20"

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
if ! which gnuplot > /dev/null 2>&1 # Test if gnuplot exists on the system
then command -v gnuplot >/dev/null 2>&1 || {
echo "gnuplot not found - skipping graph creation" >&2 echo "gnuplot not found - skipping graph creation" 1>&2
exit 1 exit 1
fi }
gnuplot<<EOF gnuplot<<EOF
set term post enhanced color solid linewidth 2.0 20 set term post enhanced color solid linewidth 2.0 20