GNU bug report logs - #50701
cannot append or insert to empty file or stream

Previous Next

Package: sed;

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


Message #15 received at 50701 <at> debbugs.gnu.org (full text, mbox):

From: Davide Brini <dave_br <at> gmx.com>
To: 50701 <at> debbugs.gnu.org
Subject: Re: bug#50701: cannot append or insert to empty file or stream
Date: Mon, 20 Sep 2021 21:40:19 +0200
On Mon, 20 Sep 2021 10:53:48 +0200, lexi hale <lexi <at> hale.su> wrote:

> 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".

It's the same thing as the following:

$ echo x > file
$ sed -i 's|^|FOO|' file
$ cat file
FOOx

$ touch empty
$ sed -i 's|^|FOO|' empty
$ cat empty
$

Would you expect a line magically materializing in the seocnd case? I
suppose you wouldn't...

--
D.




This bug report was last modified 3 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.