bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71682: sed -i '' returns error but still modify target file


From: Renato Botelho
Subject: bug#71682: sed -i '' returns error but still modify target file
Date: Thu, 20 Jun 2024 15:00:27 -0300
User-agent: Mozilla Thunderbird Beta

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]