]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/rados: improve the ls command usage 21553/head
authorLi Wang <laurence.liwang@gmail.com>
Fri, 20 Apr 2018 08:49:15 +0000 (08:49 +0000)
committerLi Wang <laurence.liwang@gmail.com>
Fri, 20 Apr 2018 08:51:49 +0000 (08:51 +0000)
Signed-off-by: Li Wang <laurence.liwang@gmail.com>
src/tools/rados/rados.cc

index 88443e40ce67dd07c7fd4d0b7b7805b60bc70bb3..9834eb021022eee7241d59172e53bfa069a76731 100644 (file)
@@ -2211,12 +2211,17 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
 
     if (wildcard)
       io_ctx.set_namespace(all_nspaces);
-    bool use_stdout = (nargs.size() < 2) || (strcmp(nargs[1], "-") == 0);
+    bool use_stdout = (!output && (nargs.size() < 2 || (strcmp(nargs[1], "-") == 0)));
+    if (!use_stdout && !output) {
+      cerr << "Please use --output to specify the output file name" << std::endl;
+      ret = -1;
+      goto out;
+    }
     ostream *outstream;
     if(use_stdout)
       outstream = &cout;
     else
-      outstream = new ofstream(nargs[1]);
+      outstream = new ofstream(output);
 
     {
       if (formatter)