summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-10-18 02:43:57 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-10-18 02:43:57 +0200
commit5fe2f863b9cee5ab0e7ac873538bce48846dbad8 (patch)
tree458909d5ff400323be81cdd88e5c7430656deffd
parentc05387d5deca9e57c38077debc0f705199f32006 (diff)
sort: -o FILE should create/truncate FILE
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/sort.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 716824321..eccc2d437 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -412,7 +412,7 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_SORT_BIG
/* Open output file _after_ we read all input ones */
if (option_mask32 & FLAG_o)
- xmove_fd(xopen(str_o, O_WRONLY), STDOUT_FILENO);
+ xmove_fd(xopen(str_o, O_WRONLY|O_CREAT|O_TRUNC), STDOUT_FILENO);
#endif
flag = (option_mask32 & FLAG_z) ? '\0' : '\n';
for (i = 0; i < linecount; i++)