[SERVER-16070] Add tilde path support to load() Created: 11/Nov/14  Updated: 16/Jan/17  Resolved: 13/Jan/17

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

Type: Improvement Priority: Minor - P4
Reporter: Stennie Steneker (Inactive) Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Won't Fix Votes: 0
Labels: neweng, polish
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Participants:

 Description   

The load() command in the mongo shell does not currently support expansion of ~ paths to the current user's home directory:

> load("~/foo.js")
2014-11-11T14:38:41.124+1100 file [~/foo.js] doesn't exist
2014-11-11T14:38:41.125+1100 Error: error loading js file: ~/foo.js

From the error message it's not entirely obvious why ~ doesn't work. The expectation is that ~ would expand to the equivalent of $HOME similar to shells like bash/zsh (i.e. "/home/user/foo.js").

Tilde paths would be useful for writing mongorc.js add-ins that can load from the user's current path. For scripting purposes, it may also be helpful to expose a getter for the $HOME directory path (eg. getHomePath()).



 Comments   
Comment by Justin Cohler [ 13/Jan/17 ]

We are not focusing on new shell features at this point.

Comment by Matt Kangas [ 11/Nov/14 ]

This should be straightforward to implement.

Note, in boost::filesystem, neither .absolute() nor .canonical() seem to perform tilde expansion.

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