From 2492f0bad75b488691f3764fab0bfc19118e3834 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 29 Sep 2014 22:31:30 +0200 Subject: [PATCH] Fix how the shell appends. --- utils/sh.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/sh.cpp b/utils/sh.cpp index a88e9757..58133d3c 100644 --- a/utils/sh.cpp +++ b/utils/sh.cpp @@ -331,8 +331,12 @@ readcmd: if ( outputfile ) { close(1); - int flags = O_CREAT | O_WRONLY | O_APPEND; - if ( strcmp(execmode, ">") == 0 ) { flags |= O_TRUNC; } + // TODO: Is this logic right or wrong? + int flags = O_CREAT | O_WRONLY; + if ( strcmp(execmode, ">") == 0 ) + flags |= O_TRUNC; + if ( strcmp(execmode, ">>") == 0 ) + flags |= O_APPEND; if ( open(outputfile, flags, 0666) < 0 ) { error(127, errno, "%s", outputfile);