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.
This commit is contained in:
Roberto E. Vargas Caballero 2025-12-13 11:52:32 +01:00
parent 5364863516
commit 08b8c73dda
2 changed files with 13 additions and 1 deletions

3
ed.c
View File

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

11
tests/0017-ed.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
../ed -s /dev/null <<EOF | grep 'file modified' > /dev/null
a
1
2
.
w !echo
q
h
EOF