mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
qualify exported FOAM_CASE
- avoid ambiguities caused by relative paths
This commit is contained in:
@ -29,6 +29,7 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IOobject.H"
|
||||
#include "IFstream.H"
|
||||
@ -41,6 +42,15 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList args(argc, argv);
|
||||
|
||||
Info<< nl
|
||||
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
|
||||
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
|
||||
<< endl;
|
||||
|
||||
|
||||
{
|
||||
dictionary dict1(IFstream("testDict")());
|
||||
Info<< "dict1: " << dict1 << nl
|
||||
|
||||
@ -14,6 +14,9 @@ FoamFile
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#inputMode merge
|
||||
#includeIfPresent "someUnknownFile"
|
||||
#includeIfPresent "$FOAM_CASE/someUnknownFile"
|
||||
#includeIfPresent "$FOAM_CASE/someUnknownFile-$FOAM_CASENAME"
|
||||
|
||||
internalField uniform 1;
|
||||
|
||||
@ -78,7 +81,6 @@ boundaryField
|
||||
// NB: the inputMode has a global scope
|
||||
#inputMode merge
|
||||
#include "testDict2"
|
||||
#includeIfPresent "SomeUnknownFile"
|
||||
|
||||
foo
|
||||
{
|
||||
|
||||
@ -129,14 +129,18 @@ void Foam::argList::getRootCase()
|
||||
casePath = iter();
|
||||
casePath.removeRepeated('/');
|
||||
casePath.removeTrailing('/');
|
||||
|
||||
// handle degenerate form and '-case .' like no -case specified
|
||||
if (casePath.empty() || casePath == ".")
|
||||
{
|
||||
casePath = cwd();
|
||||
options_.erase("case");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// nothing specified, use the current dir
|
||||
casePath = cwd();
|
||||
|
||||
// we could add this back in as '-case'?
|
||||
// options_.set("case", casePath);
|
||||
}
|
||||
|
||||
rootPath_ = casePath.path();
|
||||
@ -522,10 +526,26 @@ Foam::argList::argList
|
||||
}
|
||||
jobInfo.write();
|
||||
|
||||
|
||||
// Set the case and case-name as an environment variable
|
||||
if (rootPath_[0] == '/')
|
||||
{
|
||||
// absolute path
|
||||
setEnv("FOAM_CASE", rootPath_/globalCase_, true);
|
||||
}
|
||||
else if (rootPath_ == ".")
|
||||
{
|
||||
// relative to the current working directory
|
||||
setEnv("FOAM_CASE", cwd()/globalCase_, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// qualify relative path
|
||||
setEnv("FOAM_CASE", cwd()/rootPath_/globalCase_, true);
|
||||
}
|
||||
setEnv("FOAM_CASENAME", globalCase_, true);
|
||||
|
||||
|
||||
// Switch on signal trapping. We have to wait until after Pstream::init
|
||||
// since this sets up its own ones.
|
||||
sigFpe_.set(bannerEnabled);
|
||||
|
||||
Reference in New Issue
Block a user