-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Trivial - P5
-
None
-
Affects Version/s: 2.0.0
-
Component/s: Shell
-
Environment:Any
From code inspection of the isBalanced() function in shell/dbshell.cpp, the function is a little too eager to consider an expression balanced. It will return true if it ever finds more closing parentheses or braces than opening ones even if it has open ones of the other type. This doesn't matter much because any JavaScript with more closing elements that opening ones will generate a syntax error anyway and with command line recall and editing it is easy to fix. But perhaps the testing could be smartened up a little to be more helpful.
Example 1)
a=function({)
This puts the shell into multi-line mode even though the code has enough information to know that the line we just entered is wrong.
Example 2)
a=function(})
This does not go into multi-line mode because we have more closing braces than opening ones.
Example 3)
a=function(){existingVar.func(7)); veryLongExpression =
Even though the opening brace is unclosed, the extra right parenthesis causes the code to consider the expression balanced.
This is probably a very low priority bug and may not be worth the time to fix.
- is related to
-
SERVER-6693 Copy-pasting multi-line strings with arrays does not work in shell
- Closed
-
SERVER-13934 Escaping of parentheses/brackets/braces in shell regular expression literals does not work
- Closed
- related to
-
SERVER-14430 Shell in interactive mode does not wait for for-loop body
- Backlog
-
SERVER-5697 Unmatched quotes in regular expression cause JS shell to enter multi-line mode
- Closed
-
SERVER-5809 Double quote escaping bugged
- Closed