Skip to content

Commit

Permalink
Fixed Underscore Env Var Expansion (#5402)
Browse files Browse the repository at this point in the history
* Fixed env var expansion to include underscores

* Added test to cover change

* Added changelog entry

* Renamed tests
  • Loading branch information
acpaquette authored Jan 19, 2024
1 parent 1236400 commit 62ed4f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ release.
### Fixed
- Fixed <i>noproj</i> bug where some temporary files were not deleted after call to cam2cam. Issue: [#4813](https://github.com/USGS-Astrogeology/ISIS3/issues/4813)
- Fixed <i>noproj</i> bug where missing shapemodel-related keywords (RayTraceEngine, BulletParts, Tolerance) are dropped when the output label is created. This resulted in the Bullet collision detection engine not being used. Issue: [#5377](https://github.com/USGS-Astrogeology/ISIS3/issues/5377)
- Fixed ISIS failing to expand env variables with an "_" in them. [#5402](https://github.com/DOI-USGS/ISIS3/pull/5402)

## [8.1.0] - 2024-01-08

Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/objs/FileName/FileName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ namespace Isis {
// Loop while there are any "$" at the current position or after
// Some "$" might be skipped if no translation can be found
while((varStartPos = expandedStr.indexOf("$", varSearchStartPos)) != -1) {
int varEndPos = expandedStr.indexOf(QRegExp("[^a-zA-Z{}0-9]"), varStartPos + 1);
int varEndPos = expandedStr.indexOf(QRegExp("[^a-zA-Z{}0-9_]"), varStartPos + 1);
if (varEndPos == -1)
varEndPos = expandedStr.length();

Expand Down
10 changes: 9 additions & 1 deletion isis/tests/FileNameTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,21 @@ TEST(FileName, Extension) {
EXPECT_EQ("cub", file.extension());
}

TEST(FileName, Expanded) {
TEST(FileName, ExpandedDefault) {
QString relativeFileName("test.cub");
FileName file("$ISISROOT/" + relativeFileName);
QString isisRoot(getenv("ISISROOT"));
EXPECT_EQ(isisRoot + "/" + relativeFileName, file.expanded());
}

TEST(FileName, ExpandedUnderscore) {
QString relativeFileName("test.cub");
setenv("SOME_FILE_PATH", getenv("ISISROOT"), 1);
FileName file("$SOME_FILE_PATH/" + relativeFileName);
QString someFilePath(getenv("ISISROOT"));
EXPECT_EQ(someFilePath + "/" + relativeFileName, file.expanded());
}

TEST(FileName, Original) {
QString test = "$ISISROOT/testy/mc/test/face/test.cub";
FileName file(test);
Expand Down

0 comments on commit 62ed4f6

Please sign in to comment.