summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-01-30 14:57:45 -0500
committerAaron <aaron@10gen.com>2009-01-30 14:57:45 -0500
commit02e22ec1c206b13025cd2ce7a4cb9797ae0178d5 (patch)
tree602e63b16054d9ed48438af578bce9072ec50ac9 /shell
parent7fa1cf29da60c930771e16654de6b0ae055253f4 (diff)
parentd3aa125d87944940080d9fe8816cd4a289d3e3a0 (diff)
downloadmongo-02e22ec1c206b13025cd2ce7a4cb9797ae0178d5.tar.gz
Merge branch 'master' of ssh://aaron@git.10gen.com/data/gitroot/p
Diffstat (limited to 'shell')
-rw-r--r--shell/dbshell.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp
index 4170f7da2f3..375a851a381 100644
--- a/shell/dbshell.cpp
+++ b/shell/dbshell.cpp
@@ -28,8 +28,11 @@ void setupSignals() {
}
string fixHost( string url , string host , string port ){
- if ( host.size() == 0 && port.size() == 0 )
+ if ( host.size() == 0 && port.size() == 0 ){
+ if ( url.find( "/" ) == string::npos && url.find( "." ) != string::npos )
+ return url + "/test";
return url;
+ }
if ( url.find( "/" ) != string::npos ){
cerr << "url can't have host or port if you specify them individually" << endl;
@@ -152,7 +155,7 @@ int main(int argc, char* argv[]) {
if (strcmp(str, "-f") == 0) {
continue;
}
-
+
if (strncmp(str, "--", 2) == 0) {
printf("Warning: unknown flag %s.\nTry --help for options\n", str);
continue;
@@ -160,25 +163,34 @@ int main(int argc, char* argv[]) {
if ( nodb )
break;
- else {
- const char * last = strstr( str , "/" );
- if ( last )
- last++;
- else
- last = str;
-
- if ( ! strstr( last , "." ) ){
- url = str;
- continue;
- }
-
+
+ const char * last = strstr( str , "/" );
+ if ( last )
+ last++;
+ else
+ last = str;
+
+ if ( ! strstr( last , "." ) ){
+ url = str;
+ continue;
}
+ if ( strstr( last , ".js" ) )
+ break;
+
+ path p( str );
+ if ( ! boost::filesystem::exists( p ) ){
+ url = str;
+ continue;
+ }
+
+
break;
}
if ( !nodb ) { // init mongo code
v8::HandleScope handle_scope;
+ cout << "url: " << url << endl;
string setup = (string)"db = connect( \"" + fixHost( url , dbhost , port ) + "\")";
if ( ! ExecuteString( v8::String::New( setup.c_str() ) , v8::String::New( "(connect)" ) , false , true ) ){
return -1;