Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CS-1535: Avoid writing to stderr unless dumping to stdout

  • Loading branch information...
commit 1ffc5fd9e578ce5a9c58d04ae7f909cc2241d0f4 1 parent 8a79e63
Brandon Diamond authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 tools/dump.cpp
View
11 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 @@ class Dump : public Tool {
;
}
+ 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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.