diff --git a/jstests/run_program1.js b/jstests/run_program1.js index 267568b9b91..7984a342647 100644 --- a/jstests/run_program1.js +++ b/jstests/run_program1.js @@ -1,4 +1,4 @@ -if (runProgram('uname') == 0) { //test for a unixy environment (includes cygwin tools) +if ( ! _isWindows() ) { // note that normal program exit returns 0 assert.eq (0, runProgram('true')) @@ -12,8 +12,8 @@ if (runProgram('uname') == 0) { //test for a unixy environment (includes cygwin // numbers can be passed as numbers or strings runProgram('sleep', 0.5); runProgram('sleep', '0.5'); -} -if (runProgram('ver') == 0) { //on windows +} else { + runProgram('echo', 'Hello', 'World.', 'How are you?'); } diff --git a/shell/utils.cpp b/shell/utils.cpp index fdd3856d7c1..76eae38f385 100644 --- a/shell/utils.cpp +++ b/shell/utils.cpp @@ -600,6 +600,15 @@ namespace mongo { #endif return BSON( "" << double( r ) / ( double( RAND_MAX ) + 1 ) ); } + + BSONObj isWindows(const BSONObj& a){ + uassert( 13006, "isWindows accepts no arguments", a.nFields() == 0 ); +#ifdef _WIN32 + return BSON( "" << true ); +#else + return BSON( "" << false ); +#endif + } void installShellUtils( Scope& scope ){ scope.injectNative( "sleep" , JSSleep ); @@ -607,6 +616,8 @@ namespace mongo { scope.injectNative( "getMemInfo" , JSGetMemInfo ); scope.injectNative( "_srand" , JSSrand ); scope.injectNative( "_rand" , JSRand ); + scope.injectNative( "_isWindows" , isWindows ); + #ifndef MONGO_SAFE_SHELL //can't launch programs scope.injectNative( "_startMongoProgram", StartMongoProgram );