[SERVER-3998] It's trivial to make the new "edit" function work on Windows Created: 02/Oct/11 Updated: 11/Jul/16 Resolved: 27/Nov/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | None |
| Fix Version/s: | 2.1.0 |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Tad Marshall | Assignee: | Tad Marshall |
| Resolution: | Done | Votes: | 0 |
| Labels: | rn | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows |
||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
I was curious why the new "edit" function in the shell wasn't supported in Windows, so I tried taking out the #ifndef _WIN32 code that is hiding the function and making minor adjustments for Windows. It took 5 minutes to get it working. Windows isn't crazy about editing a file that is still open by the shell, but notepad let me overwrite the file anyway and I got my edited values back in the shell just fine. I think that closing and reopening the file (at least in Windows) is the better way to go rather than letting the editor operate on a file we still have open. I tweaked the filename generation slightly for Windows: #ifdef _WIN32 and I had to comment out the use of File to do the delete because "fd" is private in the Windows build, so my hack needs more work. The file isn't deleted with my quick hack, but that's easy to fix if we want to enable this feature in Windows. // just to make sure this gets closed no matter what I was thinking that I might need to use ShellExecute() to run the program, but ::system() works fine. No #ifdef required. StringBuilder sb; I set Visual Studio to pass --nodb on the command line and EDITOR=notepad.exe as an environment variable and except for the complaint from notepad that "The file is open in another process" it just worked. MongoDB shell version: 2.1.0-pre- > // it worked |
| Comments |
| Comment by Tad Marshall [ 27/Nov/11 ] |
|
Fixed by commit 2cad4df74dd544273fc23d0fb69429766e29a446 . |
| Comment by auto [ 27/Nov/11 ] |
|
Author: {u'login': u'', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}Message: Make the mongo shell's 'edit' command work in Windows. Change |