GNU bug report logs -
#71682
sed -i '' returns error but still modify target file
Previous Next
To reply to this bug, email your comments to 71682 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#71682
; Package
sed
.
(Thu, 20 Jun 2024 18:23:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Renato Botelho <garga <at> FreeBSD.org>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Thu, 20 Jun 2024 18:23:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I'm writing a script that needs to run with both GNU and BSD sed
implementations. I know GNU sed accepts -i without any parameter while
in BSD implementation it's mandatory. I also know that if I use -i''
without spaces between -i and '' it works on both implementations and my
problem is solved.
But I believe the behavior of GNU sed when there is a space between -i
and '' is not correct. It prints an error message and returns code 2
but it still modifies the file. Here is an example:
$ echo abcd > /tmp/f
$ sed -i '' -e 's/abcd/dcba/' /tmp/f
sed: can't read : No such file or directory
$ echo $?
2
$ cat /tmp/f
dcba
--
Renato Botelho
This bug report was last modified 190 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.