Explorar o código

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

Andreas Kling %!s(int64=6) %!d(string=hai) anos
pai
achega
dd595fe865
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      Shell/main.cpp

+ 1 - 1
Shell/main.cpp

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