Shell: A '>' redirection target should be truncated.

This commit is contained in:
Andreas Kling 2019-05-26 14:57:12 +02:00
parent d66fa60fcf
commit dd595fe865
Notes: sideshowbarker 2024-07-19 13:56:01 +09:00

View file

@ -296,7 +296,7 @@ static int run_command(const String& cmd)
break;
}
case Redirection::FileWrite: {
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT, 0666);
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
perror("open");
return 1;