[SERVER-4009] The shell's new 'edit' command could edit line text as well as objects Created: 04/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: Improvement Priority: Minor - P4
Reporter: Tad Marshall Assignee: Tad Marshall
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Any


Backwards Compatibility: Fully Compatible
Participants:

 Description   

The code for the 'edit' command in shell/dbshell.cpp scans the line it is passed to see if parses as the name of an object or property. If the text is not the name of an object, it prints "can only edit variable or property" and returns.

But it could just as easily save the text of the line to the temporary file it creates and pass the input line to the editor. Especially combined with command line recall of multi-line commands, this could be pretty helpful to heavy shell users.

Type a very long multi-line bit of JavaScript and get an error from the shell. Press up-arrow to recall the entire command, press Home to go to the beginning of the line, type "edit " and hit return. Your multi-line command is now in the editor.

Note that multi-line commands have to have newlines stripped (replaced by spaces) to work right with the line oriented editing of the command line and also to be compatible with the history file. We could be fancy and pretty up the text before passing it to the editor and then strip newlines again on return, but the feature would be useful even without that.



 Comments   
Comment by auto [ 11/Mar/12 ]

Author:

{u'login': u'tadmarshall', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-4009 Allow edit command to edit the command line

If the text following "edit " does not parse as a single JavaScript
variable name, pass the rest of the command line to the editor and
preload the edited text into the command line on return from the editor.
Branch: master
https://github.com/mongodb/mongo/commit/dbd354f2c3327c3d2a46a1e59c58541324785d1e

Comment by Kenny Gorman [ 23/Jan/12 ]

YES! Can we have this please?

Generated at Thu Feb 08 03:04:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.