commit 08b8c73ddaf92727f8e9a93f2c0d60eb0183caa4
parent 5364863516ace9b153ba5508c07baacef86127bc
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Sat, 13 Dec 2025 11:52:32 +0100
ed: Don't clear modflag in shell escapes
The function dowrite() is used for normal writes and for shell
escapes and in the second case we don't have the actual file
saved to disk.
Diffstat:
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/ed.c b/ed.c
@@ -795,7 +795,8 @@ dowrite(const char *fname, int trunc)
if (r)
error("input/output error");
strcpy(savfname, fname);
- modflag = 0;
+ if (!sh)
+ modflag = 0;
curln = line;
if (optdiag)
printf("%zu\n", bytecount);
diff --git a/tests/0017-ed.sh b/tests/0017-ed.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+../ed -s /dev/null <<EOF | grep 'file modified' > /dev/null
+a
+1
+2
+.
+w !echo
+q
+h
+EOF