mirror of
git://git.suckless.org/sbase
synced 2026-01-26 13:43:17 +00:00
ed: Don't clear modflag until is safe
Setting modflag unconditionally in the E command could produce that after an error happening dealing with the E command then unsaved files were silently ignored.
This commit is contained in:
parent
9a0d04fcf9
commit
8227fbab2e
4
ed.c
4
ed.c
@ -1448,17 +1448,17 @@ repeat:
|
||||
chkprint(0);
|
||||
break;
|
||||
case 'E':
|
||||
modflag = 0;
|
||||
case 'e':
|
||||
ensureblank();
|
||||
if (nlines > 0)
|
||||
goto unexpected;
|
||||
if (modflag)
|
||||
if (cmd == 'e' && modflag)
|
||||
goto modified;
|
||||
setscratch();
|
||||
deflines(curln, curln);
|
||||
doread(getfname(cmd));
|
||||
clearundo();
|
||||
modflag = 0;
|
||||
break;
|
||||
default:
|
||||
error("unknown command");
|
||||
|
||||
12
tests/0015-ed.sh
Executable file
12
tests/0015-ed.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
../ed -s /dev/null <<EOF | grep 'file modified' > /dev/null
|
||||
a
|
||||
1
|
||||
2
|
||||
.
|
||||
1E
|
||||
q
|
||||
h
|
||||
q
|
||||
EOF
|
||||
Loading…
x
Reference in New Issue
Block a user