Skip to content

Commit dd595fe

Browse files
committed
Shell: A '>' redirection target should be truncated.
1 parent d66fa60 commit dd595fe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Shell/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int run_command(const String& cmd)
296296
break;
297297
}
298298
case Redirection::FileWrite: {
299-
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT, 0666);
299+
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
300300
if (fd < 0) {
301301
perror("open");
302302
return 1;

0 commit comments

Comments
 (0)