浏览代码

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

Andreas Kling 6 年之前
父节点
当前提交
dd595fe865
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Shell/main.cpp

+ 1 - 1
Shell/main.cpp

@@ -296,7 +296,7 @@ static int run_command(const String& cmd)
                     break;
                     break;
                 }
                 }
                 case Redirection::FileWrite: {
                 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) {
                     if (fd < 0) {
                         perror("open");
                         perror("open");
                         return 1;
                         return 1;