sed(1) q command with -i option don't writeback temporary file
Issue #257
resolved
from FreeBSD’s bugzilla
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230507
expected:
$ jot 5 >a
$ sed -i.bak '2q' a
$ cat a.bak
1
2
3
4
5
$ cat a
1
2
but actually:
$ jot 5 >a
$ sed -i.bak '2q' a
$ cat a.bak
cat: a.bak: No such file or directory
$ cat a
1
2
3
4
5
$ ls
a sed00021986aa
analysis:
- backup file is not created
- original file is not edited
- temporary file(sedXXXXXXXXXX) is here
Comments (2)
-
reporter -
reporter - changed status to resolved
BUGFIX: Issue
#257- sed(1) q command with -i option don't writeback temporary file from FreeBSD's bugzilla https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230507 - backup file is not created - original file is not edited - temporary file(sedXXXXXXXXXX) is hereFreeBSD and OpenBSD fix different way, so I adopted OpenBSD's patch:
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/extern.h.diff?r1=1.13&r2=1.14 https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/main.c.diff?r1=1.37&r2=1.38 https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/process.c.diff?r1=1.33&r2=1.34
→ <<cset 22d326e975a9>>
- Log in to comment
FreeBSD’s fix:
https://svnweb.freebsd.org/base?view=revision&revision=338375
OpenBSD’s fix
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/extern.h.diff?r1=1.13&r2=1.14
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/main.c.diff?r1=1.37&r2=1.38
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sed/process.c.diff?r1=1.33&r2=1.34
both are different way, i think OpenBSD’s reasonable.