sed -i

Pedro Giffuni pfg at
Wed Jul 2 23:18:47 UTC 2014

On 07/02/14 17:21, Bryan Drewery wrote:
> On 7/2/2014 5:17 PM, Jilles Tjoelker wrote:
>> On Wed, Jul 02, 2014 at 04:21:42PM -0500, Bryan Drewery wrote:
>>> On 6/27/2014 4:15 PM, Pedro Giffuni wrote:
>>>> While here, there is also the sed(1) syntax issue:
>>>> Adopting both changes would probably reduce to a minimum the use of
>>>> GNU sed in the ports tree, but such changes are likely to be
>>>> controversial(?) and I don’t feel like wearing asbestos underwear at
>>>> this time .. at least not for sed ;).
>>> IMHO yes that is a good thing to bring over as it helps with people
>>> coming from other platforms and improves portability with scripts. I
>>> started on Linux and kept wondering why I had FILEe files all over my
>>> system until I realized -i '' was required on FreeBSD.
>> What are your ideas about the breakage this will cause? sed -i was
>> proposed in the Austin Group, but standardization broke down on this
>> issue.
>> Even a simple grep for 'sed -i' finds a few dozen uses in FreeBSD base
>> that would be broken, for example:
> Breaking -i '' is not acceptable.
> I can't find the patch in question, but from the linked issue I found:
> It seems to address the backwards-compat concern.

FWIW, that patch is not in illumos [1].

>> etc/Makefile:	sed -i "" -e 's;.*/usr/libexec/atrun;#&;' ${DESTDIR}/etc/crontab
>> On the other hand,
>> usr.sbin/pc-sysinstall/backend/	sed -i -e "s|my.domain|${HOSTNAME} ${HOSTNAME}|g" ${FSMNT}/etc/hosts
>> appears to attempt to use the GNU form.
>> Also, where a backup suffix is deliberately given, it is always attached
>> to -i. Therefore, it would work for the scripts in FreeBSD base to use
>> the GNU behaviour except that an empty argument after an argumentless -i
>> option counts as an argument to that -i option anyway.

Undoubtedly backwards compatibility is a concern:
we should add a test for this (if there isn't already).


[1] Check history on:

More information about the freebsd-standards mailing list