diff options
author | Brandon Diamond <brandon@10gen.com> | 2011-10-28 16:28:25 -0400 |
---|---|---|
committer | Brandon Diamond <brandon@10gen.com> | 2011-10-28 16:28:55 -0400 |
commit | 1ffc5fd9e578ce5a9c58d04ae7f909cc2241d0f4 (patch) | |
tree | 41eb55dc0e80dbfd8c570d6282b56993ada13824 /tools | |
parent | 8a79e63cbc99be8f475fa0451095f07a9ac27e5b (diff) | |
download | mongo-1ffc5fd9e578ce5a9c58d04ae7f909cc2241d0f4.tar.gz |
CS-1535: Avoid writing to stderr unless dumping to stdout
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dump.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/dump.cpp b/tools/dump.cpp index e02d725196d..626c2cc6ff9 100644 --- a/tools/dump.cpp +++ b/tools/dump.cpp @@ -37,7 +37,7 @@ class Dump : public Tool { FILE* _f; }; public: - Dump() : Tool( "dump" , ALL , "*" , "*" , false ) { + Dump() : Tool( "dump" , ALL , "*" , "*" , true ) { add_options() ("out,o", po::value<string>()->default_value("dump"), "output directory or \"-\" for stdout") ("query,q", po::value<string>() , "json query" ) @@ -47,6 +47,15 @@ public: ; } + virtual void preSetup() { + string out = getParam("out"); + if ( out == "-" ) { + // write output to standard error to avoid mangling output + // must happen early to avoid sending junk to stdout + useStandardOutput(false); + } + } + virtual void printExtraHelp(ostream& out) { out << "Export MongoDB data to BSON files.\n" << endl; } |