From 08b8c73ddaf92727f8e9a93f2c0d60eb0183caa4 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Sat, 13 Dec 2025 11:52:32 +0100 Subject: [PATCH] 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. --- ed.c | 3 ++- tests/0017-ed.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 tests/0017-ed.sh diff --git a/ed.c b/ed.c index ede4c51..3775b59 100644 --- 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 new file mode 100755 index 0000000..26c4b29 --- /dev/null +++ b/tests/0017-ed.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +../ed -s /dev/null < /dev/null +a +1 +2 +. +w !echo +q +h +EOF