Files
linux-stable-mirror/scripts
Rong Zhang a75c339a69 scripts/config: Use in-place editing (-i) in sed portably
The use of in-place editing was removed by commit 83e8b90e1d
("scripts/config: use sed's POSIX interface").

Before that, the script used bare `-i' to skip creating a backup file.
In fact, major sed implementations have supported `-i' for over a
decade. It's really doubtful if anyone would still build Linux on a Unix
system without it. The issue is more about how we use it:

FreeBSD and macOS disallow bare `-i'. To skip creating a backup, an
empty string ("zero-length extension") must be passed as a separate
argument following `-i'.

GNU and other BSDs accept bare `-i' to skip creating a backup, but
disallow passing a zero-length extension.

That being said, when thinking about it optimistically, using `-i' is
portable as long as a backup is created.

Use in-place editing (-i) in a portable manner by creating a backup file
with a .swp extension (the same name as the current temporary file). The
backup file will be deleted on exit.

A rough benchmark with ~1000 editions showed a 14.4% speedup (5.27s =>
4.51s, GNU sed). The FreeBSD sed showed a similar speedup.

Reviewed-by: Nicolas Schier <nsc@kernel.org>
Signed-off-by: Rong Zhang <i@rong.moe>
Link: https://patch.msgid.link/20260722-config-sed-v2-2-9f2c4b164666@rong.moe
Signed-off-by: Nicolas Schier <nsc@kernel.org>
2026-08-05 14:52:00 +02:00
..
2026-08-05 14:46:49 +02:00
2026-01-11 06:09:11 -10:00