GNU bug report logs -
#50701
cannot append or insert to empty file or stream
Previous Next
Reported by: lexi hale <lexi <at> hale.su>
Date: Mon, 20 Sep 2021 14:58:02 UTC
Severity: normal
Tags: notabug
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
there is an inconsistency in the handling of the a and i commands in
sed. if the input stream or file immediately yields EOL, sed ignores
the commands and produces an empty stream.
for instance:
$ echo -n >file line-1
$ sed -i aline-2 file
$ cat file
correctly yields
line-1
line-2
however,
$ touch empty
$ sed -i aline-1 empty
$ cat empty
prints nothing, instead of the expected result "line-1".
this is an extremely surprising behavior that limits the utility of sed
when one cannot predict the contents of the file in question. if it is
strictly necessary for standards conformance or to meet the
expectations of ancient shell scripts that depend on nonstandard
behavior, it would be helpful to at least have a flag that would turn
on consistent behavior for these commands.
however, making the consistent behavior the new default might also fix
a few extremely rare bugs in existing shell scripts :)
thanks for your time,
lexi
This bug report was last modified 3 years and 297 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.