[SERVER-3999] Allow EDITOR for shell's edit command to be set in JavaScript Created: 02/Oct/11 Updated: 05/Nov/15 Resolved: 11/Mar/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | None |
| Fix Version/s: | 2.1.1 |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Tad Marshall | Assignee: | Tad Marshall |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Any that supports the shell's "edit" feature |
||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Participants: | |||||
| Description |
|
Just a suggestion. It's great that we let the user specify what editor to use to edit JavaScript objects in the shell, but it's less great that we REQUIRE them to specify the editor. The problem is that by the time you see the message, it is too late. You would have to exit the shell and restart it to edit the object you just created. And the object won't be there unless you create it again, MongoDB shell version: 2.1.0-pre- Nobody much likes Windows NotePad, but it works and would get the job done. On Linux, perhaps we could run vi or emacs and I forget the name of the Mac default editor but there is one. This value would only be used in the case where EDITOR is not defined, so we could change the message to the EDITOR environment variable is not defined, defaulting to vi |
| Comments |
| Comment by auto [ 11/Mar/12 ] | ||
|
Author: {u'login': u'tadmarshall', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}Message: In the shell's edit command, use a JavaScript EDITOR string | ||
| Comment by Tad Marshall [ 10/Mar/12 ] | ||
|
I dropped my original idea of picking some default editor in favor of my second idea of letting the user set a JavaScript string to specify their editor. This solves the basic problem (no way to set an environment variable from inside the shell and so no way to work around the error) in a flexible way and leaves the user in control. The fix will use the JavaScript string in preference to the environment variable if it is set, which lets users override the editor used outside of the shell with a different choice inside the shell if they want. The EDITOR JavaScript variable could be set in the .mongorc.js if desired for convenience and even then could be overridden at run-time with a new setting. It's also hardly any code. If the editor is in the PATH, the command is very simple:
On Windows, if the editor is not on the PATH and is in a nested directory where the path has spaces, it's more work:
You need to force quotes into the string and double the backslashes, but it works. | ||
| Comment by Tad Marshall [ 07/Oct/11 ] | ||
|
An additional thing we could do is allow the user to set a JavaScript variable to their editor. MongoDB shell version: 2.1.0-pre- |