/*
- * Splice stdout to file
+ * Splice stdin to file
*/
#include <stdio.h>
#include <stdlib.h>
static int usage(char *name)
{
- fprintf(stderr, "%s: [-m] out_file\n", name);
+ fprintf(stderr, "... | %s: [-m] out_file\n", name);
return 1;
}
{
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");