summaryrefslogtreecommitdiff
path: root/src/mongo/shell/mongo_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/shell/mongo_main.cpp')
-rw-r--r--src/mongo/shell/mongo_main.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/shell/mongo_main.cpp b/src/mongo/shell/mongo_main.cpp
index 1b9ec083b5e..585e1adce17 100644
--- a/src/mongo/shell/mongo_main.cpp
+++ b/src/mongo/shell/mongo_main.cpp
@@ -844,6 +844,15 @@ int mongo_main(int argc, char* argv[]) {
mongo::getGlobalScriptEngine()->enableJavaScriptProtection(
shellGlobalParams.javascriptProtection);
+ if (shellGlobalParams.files.size() > 0) {
+ boost::system::error_code ec;
+ auto loadPath =
+ boost::filesystem::canonical(shellGlobalParams.files[0], ec).parent_path().string();
+ if (!ec) {
+ mongo::getGlobalScriptEngine()->setLoadPath(loadPath);
+ }
+ }
+
ScopeGuard poolGuard([] { ScriptEngine::dropScopeCache(); });
std::unique_ptr<mongo::Scope> scope(mongo::getGlobalScriptEngine()->newScope());