From 563f8315451d4a046c099291596708fe1c0fe4e5 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 4 Mar 2012 16:50:44 +0100 Subject: [PATCH] The shell now support the >> operator. Note that the RAM filesystem, however, doesn't. --- utils/mxsh.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/mxsh.cpp b/utils/mxsh.cpp index daa54207..be866610 100644 --- a/utils/mxsh.cpp +++ b/utils/mxsh.cpp @@ -37,6 +37,7 @@ readcmd: strcmp(token, "&") == 0 || strcmp(token, "|") == 0 || strcmp(token, ">") == 0 || + strcmp(token, ">>") == 0 || false ) { break; @@ -58,7 +59,7 @@ readcmd: } outputfile = NULL; - if ( strcmp(execmode, ">") == 0 ) + if ( strcmp(execmode, ">") == 0 || strcmp(execmode, ">>") == 0 ) { outputfile = tokens[cmdend+1]; if ( !outputfile ) { fprintf(stderr, "expected filename\n"); goto out; } @@ -141,7 +142,10 @@ readcmd: if ( outputfile ) { close(1); - if ( open(outputfile, O_CREAT | O_WRONLY | O_TRUNC | O_APPEND) < 0 ) + int flags = O_CREAT | O_WRONLY | O_APPEND; + fprintf(stderr, "execmode = %s\n", execmode); + if ( strcmp(execmode, ">") == 0 ) { flags |= O_TRUNC; } + if ( open(outputfile, flags, 0666) < 0 ) { error(127, errno, "%s", outputfile); }