diff --git a/README.md b/README.md
index 024b2c1a61..7aa40e309b 100644
--- a/README.md
+++ b/README.md
@@ -68,7 +68,7 @@ not guaranteed to have any correspondence to the OpenFOAM release
information is embedded into each application. For example, as
displayed from `blockMesh -help`:
```
-Using: OpenFOAM-v1812.local (1812) (see www.OpenFOAM.com)
+Using: OpenFOAM-v1812.local (1812) - see www.OpenFOAM.com
Build: 65d6551ff7-20190530 (patch=190531)
Arch: LSB;label=32;scalar=64
```
diff --git a/bin/tools/openfoam b/bin/tools/openfoam
new file mode 100755
index 0000000000..a9212642d2
--- /dev/null
+++ b/bin/tools/openfoam
@@ -0,0 +1,178 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# ========= |
+# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+# \\ / O peration |
+# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
+# \\/ M anipulation |
+#-------------------------------------------------------------------------------
+# License
+# This file is part of OpenFOAM, licensed under GNU General Public License
+# .
+#
+# Script
+# openfoam [args]
+#
+# Description
+# Open an interactive bash session with an OpenFOAM environment,
+# or run an OpenFOAM application (with arguments) after first sourcing
+# the OpenFOAM etc/bashrc file from the project directory.
+#
+# This script normally exists in $WM_PROJECT_DIR/bin/tools
+#
+#------------------------------------------------------------------------------
+# Hard-coded value (eg, with autoconfig)
+projectDir="@PROJECT_DIR@"
+
+if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
+then
+ # Auto-detect from location
+ toolsDir="${0%/*}" # The bin/tools dir
+ projectDir="${toolsDir%/bin/tools}" # Project dir
+
+ if [ "$projectDir" = "$toolsDir" ] # Need to try harder
+ then
+ projectDir="$(\cd $(dirname $0)/../.. && \pwd -L)" || unset projectDir
+ fi
+fi
+
+#------------------------------------------------------------------------------
+usage() {
+ exec 1>&2
+ while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+ cat<&2
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+done
+
+#-------------------------------------------------------------------------------
+
+# Remove current OpenFOAM environment
+if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ]
+then
+ . "$WM_PROJECT_DIR/etc/config.sh/unset"
+fi
+
+[ -d "$projectDir" ] || {
+ echo "Error: no project dir: $projectDir" 1>&2
+ exit 2
+}
+
+_foamSourceBashEnv="$projectDir/etc/bashrc"
+
+if [ "$#" -eq 0 ]
+then
+ # Interactive shell
+ _foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
+fi
+
+[ -f "$_foamSourceBashEnv" ] || {
+ echo "Error: file not found: $_foamSourceBashEnv" 1>&2
+ exit 2
+}
+
+if [ "$#" -eq 0 ]
+then
+ # Source user ~/.bashrc and OpenFOAM etc/bashrc.
+ # 1) Can either use a tmp file, or 2) chain off to a dedicated file
+ # We use a dedicated file.
+
+ if [ -n "$_foamSettings" ]
+ then
+ export FOAM_SETTINGS="$_foamSettings"
+ fi
+
+ ## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
+
+ # Interactive shell (newer bash can use --init-file instead of --rcfile)
+ exec bash --rcfile "$_foamSourceBashEnv" -i
+
+else
+ # Non-interactive
+
+ # Source bashrc within a function to preserve command-line arguments
+ # - this will not have aliases, but working non-interactively anyhow
+ sourceBashrc()
+ {
+ . "$_foamSourceBashEnv" $_foamSettings
+ }
+
+ sourceBashrc
+ exec "$@"
+fi
+
+#------------------------------------------------------------------------------
diff --git a/bin/tools/source-bashrc b/bin/tools/source-bashrc
new file mode 100644
index 0000000000..01c8fe37ee
--- /dev/null
+++ b/bin/tools/source-bashrc
@@ -0,0 +1,93 @@
+#----------------------------------*-sh-*--------------------------------------
+# ========= |
+# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+# \\ / O peration |
+# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
+# \\/ M anipulation |
+#------------------------------------------------------------------------------
+# License
+# This file is part of OpenFOAM, licensed under GNU General Public License
+# .
+#
+# File
+# bin/tools/source-bashrc
+#
+# Description
+# Source user ~/.bashrc and OpenFOAM etc/bashrc
+#
+# This file is normally not sourced manually,
+# but from bash with the --rcfile option.
+#------------------------------------------------------------------------------
+# Hard-coded value (eg, with autoconfig)
+projectDir="@PROJECT_DIR@"
+
+if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
+then
+ # Auto-detect (as per OpenFOAM etc/bashrc)
+ # --
+ # Assuming this file is $WM_PROJECT_DIR/bin/tools/source-bashrc,
+ # the next lines should work when sourced by BASH or ZSH shells.
+ # --
+
+ projectDir="${BASH_SOURCE:-${ZSH_NAME:+$0}}"
+ [ -n "$projectDir" ] && projectDir="$(\cd $(dirname $projectDir)/../.. && \pwd -L)" || unset projectDir
+fi
+
+#------------------------------------------------------------------------------
+
+if [ -d "$projectDir" ]
+then
+ _foamSourceBashEnv="$projectDir/etc/bashrc"
+else
+ unset _foamSourceBashEnv
+fi
+
+
+# Source the user bashrc first.
+# Simply hope that they don't unset/reset _foamSourceBashEnv !!
+
+if [ -f "$HOME/.bashrc" ]
+then
+ . "$HOME/.bashrc"
+fi
+
+
+# Source the OpenFOAM etc/bashrc
+
+if [ -f "$_foamSourceBashEnv" ]
+then
+ . "$_foamSourceBashEnv" $FOAM_SETTINGS
+
+ # Avoid further inheritance
+ unset FOAM_SETTINGS
+
+ # Some feedback
+ if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ]
+ then
+ info="$(foamEtcFile -show-patch 2>/dev/null)"
+
+ # echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - see www.OpenFOAM.com" 1>&2
+ echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - see www.OpenFOAM.com" 1>&2
+ echo "Arch: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
+
+ ## echo "$WM_PROJECT_DIR" 1>&2
+ ## echo 1>&2
+
+ # Set prompt as reminder that this is a shell session
+
+ # Chalmers likes this one:
+ # PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'$(foamPwd)\n\u\$ '
+
+ PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'\w/\n\u\$ '
+ fi
+else
+ echo "Could not locate OpenFOAM etc/bashrc in '$projectDir'" 1>&2
+fi
+
+echo "OpenFOAM shell session - use exit to quit" 1>&2
+echo 1>&2
+
+# Cleanup variables (done as final statement for a clean exit code)
+unset _foamSourceBashEnv projectDir
+
+#------------------------------------------------------------------------------
diff --git a/etc/bashrc b/etc/bashrc
index da3ab5b8cc..9de44922f9 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -95,6 +95,8 @@ projectDir="$HOME/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
# projectDir="/opt/openfoam/OpenFOAM-$WM_PROJECT_VERSION"
# projectDir="/usr/local/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
################################################################################
+# Or optionally hard-coded (eg, with autoconfig)
+# projectDir="@PROJECT_DIR@"
: # Safety statement (if the user removed all fallback values)
# [FOAM_SIGFPE] - Trap floating-point exceptions.
diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases
index 9ead10e19f..00b1620250 100644
--- a/etc/config.sh/aliases
+++ b/etc/config.sh/aliases
@@ -2,7 +2,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
-# \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
+# \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# | Copyright (C) 2011-2016 OpenFOAM Foundation
@@ -111,15 +111,16 @@ foamPV()
unset -f foamPwd 2>/dev/null
foamPwd()
{
- if [ -d "$WM_PROJECT_DIR" ]
+ if [ -n "$WM_PROJECT_DIR" ]
then
- echo "$PWD" | sed \
- -e "s#^${FOAM_RUN}#\$FOAM_RUN#;" \
- -e "s#^${WM_PROJECT_DIR}#\$WM_PROJECT_DIR#;" \
- -e "s#^${WM_PROJECT_USER_DIR}#\$WM_PROJECT_USER_DIR#;" \
- -e "s#^${HOME}#\$HOME#";
+ echo "$PWD/" | sed \
+ -e "s#^${FOAM_RUN}/#\$FOAM_RUN/#" \
+ -e "s#^${WM_PROJECT_DIR}/#\$WM_PROJECT_DIR/#" \
+ -e "s#^${WM_PROJECT_USER_DIR}/#\$WM_PROJECT_USER_DIR/#" \
+ -e "s#^${HOME}/#~/#" \
+ ;
else
- echo "$PWD" | sed -e "s#^${HOME}#\$HOME#;"
+ echo "$PWD/" | sed -e "s#^${HOME}/#~/#";
fi
}
diff --git a/etc/cshrc b/etc/cshrc
index bd889519fe..699d4d705c 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -98,6 +98,8 @@ set projectDir=`lsof +p $$ |& \
# set projectDir="/opt/openfoam/OpenFOAM-$WM_PROJECT_VERSION"
# set projectDir="/usr/local/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
################################################################################
+# Or optionally hard-coded (eg, with autoconfig)
+# set projectDir="@PROJECT_DIR@"
# [FOAM_SIGFPE] - Trap floating-point exceptions.
# - overrides the 'trapFpe' controlDict entry
diff --git a/src/OpenFOAM/global/version/foamVersion.C b/src/OpenFOAM/global/version/foamVersion.C
index 0a11350559..5538821312 100644
--- a/src/OpenFOAM/global/version/foamVersion.C
+++ b/src/OpenFOAM/global/version/foamVersion.C
@@ -44,7 +44,7 @@ bool Foam::foamVersion::patched()
void Foam::foamVersion::printBuildInfo(const bool full)
{
Info<< "Using: OpenFOAM-" << foamVersion::version.c_str()
- << " (" << foamVersion::api << ") (see www.OpenFOAM.com)\n"
+ << " (" << foamVersion::api << ") - see www.OpenFOAM.com\n"
<< "Build: " << foamVersion::build.c_str();
if (foamVersion::patched())