← Commit list

5ae25f40b

Ron Yorston
Ron Yorston
2021-03-29
SUCCESS Duration: 152s

Subject

vi: don't overwrite existing file

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

editors/vi.c+7 -0
@@ -2816,6 +2816,13 @@ static void colon(char *buf)
// is there a file name to write to?
if (args[0]) {
+ struct stat statbuf;
+
+ if (!useforce && (fn == NULL || strcmp(fn, args) != 0) &&
+ stat(args, &statbuf) == 0) {
+ status_line_bold("File exists (:w! overrides)");
+ goto ret;
+ }
fn = args;
}
# if ENABLE_FEATURE_VI_READONLY