summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBrandon Diamond <brandon@10gen.com>2011-10-28 16:28:25 -0400
committerBrandon Diamond <brandon@10gen.com>2011-10-28 16:28:55 -0400
commit1ffc5fd9e578ce5a9c58d04ae7f909cc2241d0f4 (patch)
tree41eb55dc0e80dbfd8c570d6282b56993ada13824 /tools
parent8a79e63cbc99be8f475fa0451095f07a9ac27e5b (diff)
downloadmongo-1ffc5fd9e578ce5a9c58d04ae7f909cc2241d0f4.tar.gz
CS-1535: Avoid writing to stderr unless dumping to stdout
Diffstat (limited to 'tools')
-rw-r--r--tools/dump.cpp11
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;
}