Truncate files written with "-o".

This commit is contained in:
Andrew Wood
2024-06-08 22:02:11 +01:00
parent 01e0290d6e
commit 2bed6776e4
3 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -348,7 +348,7 @@ invocations in a single, long, pipeline.
Write data to
.I FILE
rather than standard output. If the file already exists, it will be
overwritten from the start, but not truncated.
truncated.
.TP
.BI \-L\ RATE \fR,\ \fB\-\-rate-limit\ RATE
Limit the transfer to a maximum of
+1 -2
View File
@@ -260,8 +260,7 @@ that are explicitly switched on will be shown.
**-o FILE, \--output FILE**
: Write data to *FILE* rather than standard output. If the file
already exists, it will be overwritten from the start, but not
truncated.
already exists, it will be truncated.
**-L RATE, \--rate-limit RATE**
+1 -1
View File
@@ -306,7 +306,7 @@ int main(int argc, char **argv)
if (NULL == opts->output || 0 == strcmp(opts->output, "-")) {
pv_state_output_set(state, STDOUT_FILENO, "(stdout)");
} else {
int fd = open(opts->output, O_WRONLY | O_CREAT, 0600); /* flawfinder: ignore */
int fd = open(opts->output, O_WRONLY | O_CREAT | O_TRUNC, 0600); /* flawfinder: ignore */
/*
* flawfinder rationale: the output filename has been
* explicitly provided, and in many cases the operator will