Details
-
Bug
-
Resolution: Unresolved
-
Minor - P4
-
None
-
3.0.16, 4.0.0
-
Server Tooling & Methods
-
ALL
Description
The shellHelper's code is:
mongos> shellHelper
|
function (command, rest, shouldPrint) {
|
command = command.trim();
|
var args = rest.trim().replace(/\s*;$/, "").split("\s+"); |
if (!shellHelper[command]) |
throw Error("no command [" + command + "]"); |
var res = shellHelper[command].apply(null, args); |
if (shouldPrint) { |
shellPrintHelper(res);
|
}
|
return res; |
}
|
looking at the line which declares the "args", there's a split at the end which by the looks of it, seems to want to split the string by spaces.
The problem is that in this form it doesn't do that, the corect way should pass a "regex object" not a string
mongos> "a b".split("\s+") [ "a b" ] // not split by space |
|
|
mongos> "a\s+b".split("\s+") [ "a", "b" ] // split by the "\s+" string |
|
mongos> "a b".split(/\s+/) [ "a", "b" ] // split by space |
mongos> "a b".split(/\s+/) [ "a", "b" ] // split by multiple spaces |
|