ceph_objectstore_tool: Make --file option consistent by treating "-" as stdout/stdin

Signed-off-by: David Zafman <dzafman@redhat.com>
This commit is contained in:
David Zafman 2014-11-17 23:23:40 -08:00
parent 0d5262ac2f
commit 8c87f3284f

View File

@ -1939,9 +1939,9 @@ int main(int argc, char **argv)
file_fd = fd_none;
if (op == "export") {
if (!vm.count("file")) {
if (!vm.count("file") || file == "-") {
if (outistty) {
cerr << "stdout is a tty and no --file option specified" << std::endl;
cerr << "stdout is a tty and no --file filename specified" << std::endl;
exit(1);
}
file_fd = STDOUT_FILENO;
@ -1949,9 +1949,9 @@ int main(int argc, char **argv)
file_fd = open(file.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666);
}
} else if (op == "import") {
if (!vm.count("file")) {
if (!vm.count("file") || file == "-") {
if (isatty(STDIN_FILENO)) {
cerr << "stdin is a tty and no --file option specified" << std::endl;
cerr << "stdin is a tty and no --file filename specified" << std::endl;
exit(1);
}
file_fd = STDIN_FILENO;