1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

The shell now support the >> operator.

Note that the RAM filesystem, however, doesn't.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-03-04 16:50:44 +01:00
parent 3c12de760f
commit 563f831545

View file

@ -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);
}