From de4a1eeedbb15e538b78eadf6b383ed0a6ed841b Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 24 Jan 2018 12:15:09 +0100 Subject: [PATCH] CONFIG: improve evaluation of arguments for foamEtcFile - forward command-line arguments for paraview, where they may also be evaluated (cshrc, POSIX shell) Eg, . etc/bashrc ParaView_VERSION=5.4.1-mpipy source etc/cshrc ParaView_VERSION=5.4.1-mpipy --- bin/foamEtcFile | 40 ++++++++++++++++++++++++++++++++-------- etc/bashrc | 2 +- etc/cshrc | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/bin/foamEtcFile b/bin/foamEtcFile index ea1d1c3fbf2..195b91bdbe4 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -46,7 +46,7 @@ printHelp() { cat<<USAGE -Usage: foamEtcFile [OPTION] fileName +Usage: foamEtcFile [OPTION] fileName [-- args] foamEtcFile [OPTION] [-list|-list-test] [fileName] options: @@ -270,6 +270,31 @@ done #------------------------------------------------------------------------------- +# Split arguments into filename (for searching) and trailing bits for shell eval +# Silently remove leading ~OpenFOAM/ (as per Foam::findEtcFile) +nArgs=$# +fileName="${1#~OpenFOAM/}" +unset evalArgs + +if [ "$nArgs" -eq 1 ] +then + if [ "$1" = "--" ] + then + nArgs=0 + unset fileName + fi +elif [ "$nArgs" -ge 2 ] +then + if [ "$2" = "--" ] + then + nArgs=1 + shift 2 + evalArgs="$@" + fi +fi + + +# Get version information if [ -n "$optVersion" ] then setVersion $optVersion @@ -292,12 +317,6 @@ groupDir="${WM_PROJECT_SITE:-$prefixDir/site}" # eval echo "$i=\$$i" 1>&2 # done - -# Save the essential bits of information -# silently remove leading ~OpenFOAM/ (used in Foam::findEtcFile) -nArgs=$# -fileName="${1#~OpenFOAM/}" - # Define the various places to be searched: unset dirList case "$optMode" in (*u*) # (U)ser @@ -435,7 +454,12 @@ else echo "$verboseOutput$resolved" 1>&2 fi - echo "$shellOutput$resolved" + if [ -n "$shellOutput" ] + then + echo "$shellOutput$resolved $evalArgs" + else + echo "$resolved" + fi [ -n "$optAll" ] || break fi done diff --git a/etc/bashrc b/etc/bashrc index c7f8b7eb771..f8d87bd4ebd 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -153,7 +153,7 @@ _foamEtc -config settings # Setup for third-party packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc -config mpi -_foamEtc -config paraview +_foamEtc -config paraview -- $@ # Pass through for evaluation _foamEtc -config vtk _foamEtc -config ensight _foamEtc -config gperftools diff --git a/etc/cshrc b/etc/cshrc index a678eda3c11..8545e9f098d 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -196,7 +196,7 @@ _foamEtc -config settings # Setup for third-party packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc -config mpi -_foamEtc -config paraview +_foamEtc -config paraview -- "$FOAM_SETTINGS" # Pass through for evaluation _foamEtc -config vtk _foamEtc -config ensight ## _foamEtc -config ADIOS -- GitLab