GNU bug report logs -
#71682
sed -i '' returns error but still modify target file
Previous Next
Full log
View this message in rfc822 format
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 1 year and 58 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.