[PATCH] vmsplice2: warning fix
[splice.git] / splice-out.c
index 8210922d327819a34160936a4cd9a23592c589c0..c96c5c3c3dde9f5e48819bcf44d0226dfd31d4ee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Splice stdout to file
+ * Splice stdin to file
  */
 #include <stdio.h>
 #include <stdlib.h>
@@ -12,7 +12,7 @@ static int splice_flags;
 
 static int usage(char *name)
 {
-       fprintf(stderr, "%s: [-m] out_file\n", name);
+       fprintf(stderr, "... | %s: [-m] out_file\n", name);
        return 1;
 }
 
@@ -38,11 +38,14 @@ int main(int argc, char *argv[])
 {
        int fd, index;
 
+       if (check_input_pipe())
+               return usage(argv[0]);
+
        index = parse_options(argc, argv);
        if (index == -1 || index + 1 > argc)
                return usage(argv[0]);
 
-       fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
+       fd = open(argv[index], O_WRONLY | O_CREAT | O_TRUNC, 0644);
        if (fd < 0)
                return error("open");