diff options
author | U-ELIOT-019992DFC\Administrator <Administrator@eliot-019992dfc.(none)> | 2009-02-11 09:15:06 -0500 |
---|---|---|
committer | U-ELIOT-019992DFC\Administrator <Administrator@eliot-019992dfc.(none)> | 2009-02-11 09:15:06 -0500 |
commit | c68d42e36c5516fab7e975f6b6bd422c4779509f (patch) | |
tree | 07c11e07e649d10bff7e4a3cbeb6f9f8bb2a6ead | |
parent | b0a92ccc83de907dabcc0e9242fc3c9982712927 (diff) | |
download | mongo-c68d42e36c5516fab7e975f6b6bd422c4779509f.tar.gz |
better non-readline version of shell
-rw-r--r-- | shell/dbshell.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp index 7cbe5bf32ef..fee4fc467cc 100644 --- a/shell/dbshell.cpp +++ b/shell/dbshell.cpp @@ -22,6 +22,8 @@ void shellHistoryInit(){ #ifdef USE_READLINE using_history(); read_history( ".dbshell" ); +#else + cout << "type \"exit\" to exit" << endl; #endif } void shellHistoryDone(){ @@ -42,7 +44,10 @@ char * shellReadline( const char * prompt ){ #else printf( "> " ); char * buf = new char[1024]; - return fgets( buf , 1024 , stdin ); + char *l = fgets( buf , 1024 , stdin ); + int len = strlen( buf ); + buf[len-1] = 0; + return buf; #endif } @@ -296,7 +301,10 @@ int main(int argc, char* argv[]) { } string code = line; - + if ( code == "exit" ){ + break; + } + { string cmd = line; if ( cmd.find( " " ) > 0 ) |