diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp index d27c85df8b7..726100924c5 100644 --- a/shell/mongo_vstudio.cpp +++ b/shell/mongo_vstudio.cpp @@ -1049,9 +1049,14 @@ const StringData _jscode_raw_utils = "return res;\n" "}\n" "\n" -"shellHelper.use = function( dbname ){\n" -"db = db.getMongo().getDB( dbname );\n" -"print( \"switched to db \" + db.getName() );\n" +"shellHelper.use = function (dbname) {\n" +"var s = \"\" + dbname;\n" +"if (s == \"\") {\n" +"print(\"bad use parameter\");\n" +"return;\n" +"}\n" +"db = db.getMongo().getDB(dbname);\n" +"print(\"switched to db \" + db.getName());\n" "}\n" "\n" "shellHelper.it = function(){\n" diff --git a/shell/utils.js b/shell/utils.js index ea6475a55a8..50be66e63d8 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -1042,11 +1042,16 @@ shellHelper = function( command , rest , shouldPrint ){ shellPrintHelper( res ); } return res; -} - -shellHelper.use = function( dbname ){ - db = db.getMongo().getDB( dbname ); - print( "switched to db " + db.getName() ); +} + +shellHelper.use = function (dbname) { + var s = "" + dbname; + if (s == "") { + print("bad use parameter"); + return; + } + db = db.getMongo().getDB(dbname); + print("switched to db " + db.getName()); } shellHelper.it = function(){