diff --git a/CHANGELOG.md b/CHANGELOG.md index 92414f1011..d40826398c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ ctest FunctionalTestJigsawApollo to validate this output. [#5710](https://github - Changed `StripPolygonSeeder` and `GridPolygonSeeder` to seed individual polygons within each images multipolygon footprint [#5193](https://github.com/DOI-USGS/ISIS3/issues/5193) - Pinned SpiceQL to 1.2.0 [#5852](https://github.com/DOI-USGS/ISIS3/pull/5852) - Changed `ControlMeasure` object comparison to no longer factor in creation date for equality [#5862](https://github.com/DOI-USGS/ISIS3/pull/5862) +- in Application.cpp, converted initialization environmental variable shell commands and file read to c commands. [#5906](https://github.com/DOI-USGS/ISIS3/pull/5906) ### Fixed - Fixed Chandrayaan-2 TMC2 serial numbers by setting InstrumentId to CH2_TMC_FORE/NADIR/AFT based on the filename sensor [#5871](https://github.com/DOI-USGS/ISIS3/issues/5871) diff --git a/isis/src/base/objs/Application/Application.cpp b/isis/src/base/objs/Application/Application.cpp index 670641f4e5..69d141425e 100644 --- a/isis/src/base/objs/Application/Application.cpp +++ b/isis/src/base/objs/Application/Application.cpp @@ -976,46 +976,21 @@ namespace Isis { } /** - * Runs some printenv commands that return Isis related Enviroment Variables. + * Returns ISIS-related Enviroment Variables. * * @return PvlGroup containing Enviroment information - * @todo Replace printenv commands with c library getenv - * @todo */ PvlGroup Application::GetEnviromentInfo() { - // Create a temporary file to store console output to - FileName temp = FileName::createTempFile("$temporary/EnviromentInfo.txt"); - QString tempFile = temp.expanded(); + PvlGroup envGroup("EnviromentVariables"); - ifstream readTemp; - QString env1 = "printenv SHELL >| " + tempFile; - QString env2 = "printenv HOME >> " + tempFile; - QString env3 = "printenv PWD >> " + tempFile; - QString env5 = "printenv ISISROOT >> " + tempFile; - QString env6 = "printenv ISISDATA >> " + tempFile; - ProgramLauncher::RunSystemCommand(env1); - ProgramLauncher::RunSystemCommand(env2); - ProgramLauncher::RunSystemCommand(env3); - ProgramLauncher::RunSystemCommand(env5); - ProgramLauncher::RunSystemCommand(env6); - // Read data from temp file - char value[511]; - readTemp.open(tempFile.toLatin1().data(), ifstream::in); - readTemp.getline(value, 255); - envGroup.addKeyword(PvlKeyword("Shell", value)); - readTemp.getline(value, 255); - envGroup.addKeyword(PvlKeyword("Home", value)); - readTemp.getline(value, 255); - envGroup.addKeyword(PvlKeyword("Pwd", value)); - readTemp.getline(value, 255); - envGroup.addKeyword(PvlKeyword("ISISROOT", value)); - readTemp.getline(value, 255); - envGroup.addKeyword(PvlKeyword("ISISDATA", value)); + envGroup.addKeyword(PvlKeyword("Shell", getenv("SHELL"))); + envGroup.addKeyword(PvlKeyword("Home", getenv("HOME"))); + envGroup.addKeyword(PvlKeyword("PWD", getenv("PWD"))); + envGroup.addKeyword(PvlKeyword("ISISROOT", getenv("ISISROOT"))); + envGroup.addKeyword(PvlKeyword("ISISDATA", getenv("ISISDATA"))); + envGroup.addKeyword(PvlKeyword("SPICEQL_CACHE_DIR", getenv("SPICEQL_CACHE_DIR"))); - // remove temp file and return - QString cleanup = "rm -f " + tempFile; - ProgramLauncher::RunSystemCommand(cleanup); return envGroup; }