diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 195b91bdbe..c3c4b98585 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -16,31 +16,29 @@ # Description # Locate user/group/other file as per '#includeEtc'. # -# The -mode option can be used to allow chaining from personal settings -# to site-wide settings. -# -# For example, within the user ~/.OpenFOAM//config.sh/compiler: -# \code -# eval $(foamEtcFile -sh -mode=go config.sh/compiler) -# \endcode -# -# The -mode option is similarly used within etc/{bashrc,cshrc} to ensure +# The -mode option is used within etc/{bashrc,cshrc} to ensure # that system prefs are respected: # \code # eval $(foamEtcFile -sh -mode=o prefs.sh) # eval $(foamEtcFile -sh -mode=ug prefs.sh) # \endcode # +# The -mode option can also be used when chaining settings. +# For example, in the user ~/.OpenFOAM//config.sh/compiler +# \code +# eval $(foamEtcFile -sh -mode=go config.sh/compiler) +# \endcode +# # Environment -# - WM_PROJECT: (unset defaults to OpenFOAM) -# - WM_PROJECT_SITE: (unset defaults to PREFIX/site) -# - WM_PROJECT_VERSION: (unset defaults to detect from path) +# - WM_PROJECT (unset defaults to OpenFOAM) +# - WM_PROJECT_VERSION (unset defaults to detect from path) +# - WM_PROJECT_SITE (unset defaults to PREFIX/site) # # Note # This script must exist in one of these locations: -# - $WM_PROJECT_INST_DIR/OpenFOAM-/bin -# - $WM_PROJECT_INST_DIR/openfoam-/bin -# - $WM_PROJECT_INST_DIR/openfoam/bin (debian version) +# - PREFIX/OpenFOAM-/bin +# - PREFIX/openfoam-/bin +# - PREFIX/openfoam/bin # #------------------------------------------------------------------------------- printHelp() { @@ -55,7 +53,7 @@ options: -list-test List (existing) directories or files to be checked -mode=MODE Any combination of u(user), g(group), o(other) -prefix=DIR Specify an alternative installation prefix - -version=VER Specify alternative OpenFOAM version (eg, 3.0, 1612, ...) + -version=VER Specify alternative OpenFOAM version (eg, 1712, 1806, ...) -csh Produce 'source FILE' output for a csh eval -sh Produce '. FILE' output for a sh eval -csh-verbose As per -csh, with additional verbosity @@ -119,41 +117,33 @@ userDir="$HOME/.OpenFOAM" # Hard-coded as per foamVersion.H #------------------------------------------------------------------------------- # Guess project version or simply get the stem part of the projectDirName. -# Handle standard and debian naming conventions. +# Handle standard naming conventions: +# +# * OpenFOAM-[-extra...] +# * openfoam-[-extra...] +# * openfoam # # - projectVersion: update unless already set # # Helper variables: # - dirBase (for reassembling name) == projectDirName without the version -# - versionNum (debian packaging) -unset dirBase versionNum +unset dirBase guessVersion() { local version case "$projectDirName" in (OpenFOAM-* | openfoam-*) - # Standard naming: OpenFOAM- or openfoam- + # Dashed naming: OpenFOAM- or openfoam- dirBase="${projectDirName%%-*}-" version="${projectDirName#*-}" version="${version%%*-}" # Extra safety, eg openfoam-version-packager ;; (openfoam[0-9]*) - # Debian naming: openfoam + # Debian-style naming: openfoam dirBase="openfoam" version="${projectDirName#openfoam}" - versionNum="$version" - - # Convert digits version number to decimal delineated - case "${#versionNum}" in (2|3|4) - version=$(echo "$versionNum" | sed -e 's@\([0-9]\)@\1.@g') - version="${version%.}" - ;; - esac - - # Ignore special treatment if no decimals were inserted. - [ "${#version}" -gt "${#versionNum}" ] || unset versionNum ;; (*) @@ -174,16 +164,11 @@ setVersion() # Need dirBase when reassembling projectDirName [ -n "$dirBase" ] || guessVersion - # Debian: update x.y.z -> xyz version - if [ -n "$versionNum" ] - then - versionNum=$(echo "$projectVersion" | sed -e 's@\.@@g') - fi - - projectDirName="$dirBase${versionNum:-$projectVersion}" + projectDirName="$dirBase$projectVersion" } +#------------------------------------------------------------------------------- optMode=ugo # Default mode is always 'ugo' unset shellOutput verboseOutput unset optAll optConfig optList optVersion