[SERVER-5744] `edit` shell command should be more flexible Created: 02/May/12  Updated: 17/Aug/18  Resolved: 17/Aug/18

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Trivial - P5
Reporter: Andrew McFague Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Duplicate Votes: 0
Labels: platforms-re-triaged, shell
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Any


Issue Links:
Duplicate
duplicates SERVER-6325 using the `edit` command on undeclare... Closed
Related
is related to SERVER-5134 Allow "edit" feature to create new va... Closed
Participants:

 Description   

Currently, the `edit` command does not allow the following:

  • Opening an empty "command" (i.e., just typing `edit`)
  • Opening strings that may look like a JavaScript variable, but are not.
  • Strings that do not contain spaces or are not quoted.
    Works: edit "asd"
    Works: edit asd asd
    Does not work: edit asd
    Does not work: edit asd_asd

Since edit is being used as a connection from Mongo to $EDITOR, this functionality should be enabled.



 Comments   
Comment by Asya Kamsky [ 17/Aug/18 ]

Fixed as part of work on SERVER-6325 available since 2.4

Comment by Andrew McFague [ 02/May/12 ]

To be honest, I was hyped up on Nyquil last night, so I'm reading over the bug and I'm not quite sure what I meant by those points either.

Anyways, here's my best guess--I expect the edit command to basically be a way of editing a shell command in an external editor--and unfortunately, it doesn't always allow me to do that. For example, typing `edit asd` will just bring me to the next prompt with no error message and no editor. Basically, anything that looks like a variable (according to the code, anything with alphanumeric chars, underscores, or dots) but isn't, won't be opened in an editor. I would expect it to open up a text editor with `asd` there.

Does that make sense? I made some changes to this end here: https://github.com/amcfague/mongo/commit/ce4a640403470398c5cde6bac6c95e8b2a9b536b; its nothing complex, and all it really does is allow text that looks like a JavaScript variable to be edited, even if the eval portion on 463-464 fails.

Comment by Tad Marshall [ 02/May/12 ]

Can you flesh out your description of what these variations should do, including what you want to see happen with "Opening strings that may look like a JavaScript variable, but are not"? I imagine that a bare "edit" would place whatever text you create in the editor on the command line the way "edit mistyped-command" does but without the starting text ("mistyped-command"). What should "edit asd" and "edit asd_asd" do? We have a feature request to make "edit asd" create the variable for you ... https://jira.mongodb.org/browse/SERVER-5134 .

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