mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
The shell now supports sending stdout to a file.
This commit is contained in:
parent
724305f3a7
commit
63b622a086
1 changed files with 15 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <libmaxsi/platform.h>
|
#include <libmaxsi/platform.h>
|
||||||
#include <libmaxsi/process.h>
|
#include <libmaxsi/process.h>
|
||||||
#include <libmaxsi/sortix-keyboard.h>
|
#include <libmaxsi/sortix-keyboard.h>
|
||||||
|
@ -108,6 +109,20 @@ void command()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 3 <= argc )
|
||||||
|
{
|
||||||
|
if ( strcmp(argv[argc-2], ">") == 0 )
|
||||||
|
{
|
||||||
|
const char* file = argv[argc-1];
|
||||||
|
int outfd = open(file, O_CREAT | O_WRONLY | O_TRUNC | O_APPEND);
|
||||||
|
if ( outfd < 0 ) { printf("%s: %s\n", file, strerror(errno)); exit(127); }
|
||||||
|
close(1);
|
||||||
|
dup(outfd);
|
||||||
|
close(outfd);
|
||||||
|
argc -= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Replace the current process with another process image.
|
// Replace the current process with another process image.
|
||||||
Process::Execute(argv[0], argc, argv);
|
Process::Execute(argv[0], argc, argv);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue