From nobody Mon Jun 8 05:26:57 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E9F9264A86; Sat, 6 Jun 2026 22:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780783967; cv=pass; b=uYagRWATFQd4dggfgZwZ4xWJj57KsVI2P/DyX1wqffPtn2UWsJUfy4gGNCezvOBiYQHkPjB/ygD7MEw2t+WJTOS3LLbGLjsNCM2+kn5ew2uaDivuujDCF9cp3vEJxAvXIldg/LiZlvgeE9e9vDN6lyWOQrCdSXEVYURbVJGDw+g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780783967; c=relaxed/simple; bh=mGEvl8F3QsP+UsqM98dJ0np6VvxOefOK2xD2iNZK6zc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FoCSyKVCkT6ECXQwuV4wOJyx3WIUII1yWPiIlQbF2vPDiy6OaTNFV2DdEDAGFF6bogZHAZtkzU8ZKaMYC9LqpRRnH8LGYDD580lKzvazkbJgRhSOfEAi8CR9R3wrEIWXX+I1oVp09EEOp+eU141CihBt6gIroKsjZWsJd6y/lJw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=WQnQcDdZ; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="WQnQcDdZ" ARC-Seal: i=1; a=rsa-sha256; t=1780783963; cv=none; d=zohomail.com; s=zohoarc; b=crZHB0NX88NCebn+ZGU6Og0a/2TwME3JrM+e0bMf8HoctwH8U+vbmPmLhz3gHfOYzjUM5UnjLxFwGIgr4XzRrBG9+5wyar32/1z4Oi4gUoY/UCej/qu540SXVT5vlp+aDLcDJfhMFe6Ax5OGBLnR1+/PNAs/yQZwGK1wtunVIuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780783963; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=ztZoY9negWars0bczNfN1SLn09MUN8TUHPETpJ5Z/qg=; b=iV6Q7NgToEGf+1OHwENwyhhiiFBkugrL12JIcRxxELSlhn7RUxenxJJ6pAjsiSSCl8BrkuTRBrxVa1TL7JOC6vL4g+lTiv7BaxkNxcVoF0+UaGBcnljMuNECjcrcyPGkSq05u3uXEjTfIA//O4mh98cCZluVof3DpDmv6f4s2Cc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1780783962; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=ztZoY9negWars0bczNfN1SLn09MUN8TUHPETpJ5Z/qg=; b=WQnQcDdZvZ0n9pqW/vZgZUfbhqvVC2FZVFwKKNwUwlUtqQgVV1vFzjHEhlyAwIM6 Wm8g4uTHHIKCSkIFMvKEFPYOF4hgkN/NdxYEztvrVCozs0iDeGRU47+Dvq+juapYu7Z Dym3OQKSI217HtKBEsrwp1vNivsr9uwXTTl92Hc68EoE/sFzvmNLHpIobvlVe/YL6Gf W5CDRU0QTpWPSFcBko8yPvdtXew8JnCKHgftWOirGfr9V4ua8fSWBw1v5tZU2Gd8iVe WmlxDVdVZy2BUvIJLm6V/1YVlpWN9xK5NdPRwDsGw+O1/6g9bk9L/Oeg19Jlru8dcTW nYsQoFZ/Vg== Received: by mx.zohomail.com with SMTPS id 1780783961261214.86449769378135; Sat, 6 Jun 2026 15:12:41 -0700 (PDT) From: Rong Zhang Date: Sun, 07 Jun 2026 06:11:31 +0800 Subject: [PATCH 1/2] scripts/config: Use POSIX standard ERE (-E) in sed Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260607-config-sed-v1-1-2ff7e35de271@rong.moe> References: <20260607-config-sed-v1-0-2ff7e35de271@rong.moe> In-Reply-To: <20260607-config-sed-v1-0-2ff7e35de271@rong.moe> To: Nathan Chancellor , Nicolas Schier Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Rong Zhang X-Mailer: b4 0.16-dev-d5d98 X-ZohoMailClient: External The use of Extended Regular Expressions was removed by commit 83e8b90e1d2c ("scripts/config: use sed's POSIX interface"). Before that, the script used `-r' to enable ERE, which is indeed non-portable. However, POSIX.1-2024 [1][2] has accepted `-E' as a standard option to use ERE for matching, and major sed implementations (GNU, FreeBSD, OpenBSD, NetBSD, macOS) have supported `-E' for over two decades, so it makes no sense to use Basic Regular Expressions any more. Switch to ERE to get rid of chained calls to sed. A rough benchmark with ~1000 editions showed a 40.0% speedup (8.78s =3D> 5.27s, GNU sed). The FreeBSD sed showed a similar speedup. Link: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html [= 1] Link: https://austingroupbugs.net/view.php?id=3D528 [2] Signed-off-by: Rong Zhang --- scripts/config | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/config b/scripts/config index ea475c07de28..1f290372a4ce 100755 --- a/scripts/config +++ b/scripts/config @@ -76,7 +76,7 @@ txt_append() { # sed append cmd: 'a\' + newline + text + newline cmd=3D"$(printf "a\\%b$insert" "\n")" =20 - sed -e "/$anchor/$cmd" "$infile" >"$tmpfile" + sed -E -e "/$anchor/$cmd" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -87,7 +87,7 @@ txt_subst() { local infile=3D"$3" local tmpfile=3D"$infile.swp" =20 - sed -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfil= e" + sed -E -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmp= file" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -97,7 +97,7 @@ txt_delete() { local infile=3D"$2" local tmpfile=3D"$infile.swp" =20 - sed -e "/$text/d" "$infile" >"$tmpfile" + sed -E -e "/$text/d" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -105,14 +105,12 @@ txt_delete() { set_var() { local name=3D$1 new=3D$2 before=3D$3 =20 - name_re=3D"^($name=3D|# $name is not set)" + name_re=3D"^($name=3D.*|# $name is not set)" before_re=3D"^($before=3D|# $before is not set)" if test -n "$before" && grep -Eq "$before_re" "$FN"; then - txt_append "^$before=3D" "$new" "$FN" - txt_append "^# $before is not set" "$new" "$FN" + txt_append "$before_re" "$new" "$FN" elif grep -Eq "$name_re" "$FN"; then - txt_subst "^$name=3D.*" "$new" "$FN" - txt_subst "^# $name is not set" "$new" "$FN" + txt_subst "$name_re" "$new" "$FN" else echo "$new" >>"$FN" fi @@ -121,8 +119,7 @@ set_var() { undef_var() { local name=3D$1 =20 - txt_delete "^$name=3D" "$FN" - txt_delete "^# $name is not set" "$FN" + txt_delete "^($name=3D|# $name is not set)" "$FN" } =20 FN=3D.config --=20 2.53.0 From nobody Mon Jun 8 05:26:57 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1781530C166; Sat, 6 Jun 2026 22:12:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780783973; cv=pass; b=rCclryugEbUowQd4oCfOTcVpwUWLZmMs6oqUXi3DZhA4h6xM6GNxlmMDqZ6X8rdrj69BTkXBfwOEWL0VjpuGuVtO5LheyLjDRkMZmAAO3fCFBayBXFn9XdX63zpmukcT+odHyOSuAxc9dvRRUturQv9djXrxfoBuhaWGbENjJeY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780783973; c=relaxed/simple; bh=311dWqECn8Ud8GO1Oo3fDuNMQJKLVZ0R1SmQOnBD2ss=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JvNQ2yKOXn50JUnNXla/F7GMgJccLubFyCMxoot8QsN7bmfBzqxugDs0wG0NSkaUtWj/0P00jeSTAtfjqp38ju4ZR+2yhiEFxVORP0fFCuCKUs3lvlhxpyMSDkKp06Oaclnc91kvRIoBycaslzPu3VbqP9x5vovrnJXsl7fUrlI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b=lKuXQOEF; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rong.moe header.i=i@rong.moe header.b="lKuXQOEF" ARC-Seal: i=1; a=rsa-sha256; t=1780783966; cv=none; d=zohomail.com; s=zohoarc; b=i92uvlhCrqxPl3duQLweMzP+LoHSmKHmBsROUWayb9ei7FNJEduCkGw53fGhTGb0SZHSAyFv86eF9Tj18nHiL/Ix2F1MIiqBZt7Glyd+DlqfhrKp+Y1H3bM/vCLVjqeKzC08KB0P1pax61E/ZS9gcaq5v//cu4S2g5o241ZxBnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780783966; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=r5BaDtXtSWBegRS1sSzl5ZrQ7MUzeyL4GUQbwM3pgP0=; b=Khk+4SC2mFdAyByIzcM4/cFVm7xLlDMv2A83wzU651IeTNXUc8HhmEgoIzLkADgG2CMiMUi43jZ+cxQ0iYxzIqlYZGs1VgycZXy4SNksvUhWe/4n4dEbPtOAnrJxCswHcom26it/Om4gGKJPKOl1GsTt/zPw/Kqc9zPla32lkHA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1780783966; s=zmail2048; d=rong.moe; i=i@rong.moe; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=r5BaDtXtSWBegRS1sSzl5ZrQ7MUzeyL4GUQbwM3pgP0=; b=lKuXQOEFsgFo+RXKYzZUg3s9TOHMWg2RfcBx59QJQq4Q1WOglhHJC1qYFzwRqK5/ xu4jPGNwtUcTx/4QFNjE4jvWxK0p5fOmo3Xjel6GOI08t9xVw+JEWk4NCkHisZs1E1H RnwlS4Uz+GuO2E4KAIvyZhH5ZomTeuCcmFhHi8lqJ9toOEMTR73pd50NleR07BU9PPf GRoNybVtjGU+c/585790LNW+QoY0LqchM/HC9uXsCh+bthYgLxkrxesyXiZp2DRiytv ONgCmoHPXRoOaU18omvznEAavmJ9MMWPpPhYfykFGcxrNpCWr9ibyNzkErcJMm8YzPJ wyp0NMCrOw== Received: by mx.zohomail.com with SMTPS id 1780783964653715.3159320139267; Sat, 6 Jun 2026 15:12:44 -0700 (PDT) From: Rong Zhang Date: Sun, 07 Jun 2026 06:11:32 +0800 Subject: [PATCH 2/2] scripts/config: Use in-place editing (-i) in sed portably Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260607-config-sed-v1-2-2ff7e35de271@rong.moe> References: <20260607-config-sed-v1-0-2ff7e35de271@rong.moe> In-Reply-To: <20260607-config-sed-v1-0-2ff7e35de271@rong.moe> To: Nathan Chancellor , Nicolas Schier Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Rong Zhang X-Mailer: b4 0.16-dev-d5d98 X-ZohoMailClient: External The use of in-place editing was removed by commit 83e8b90e1d2c ("scripts/config: use sed's POSIX interface"). Before that, the script used bare `-i' to enable ERE while skipping creating a backup file. In fact, mojor sed implementations have supported `-i' for over a decade. It's really doubtful if anyone would still compile 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 =3D> 4.51s, GNU sed). The FreeBSD sed showed a similar speedup. Signed-off-by: Rong Zhang --- scripts/config | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/config b/scripts/config index 1f290372a4ce..6b6db22f5408 100755 --- a/scripts/config +++ b/scripts/config @@ -71,35 +71,31 @@ txt_append() { local anchor=3D"$1" local insert=3D"$2" local infile=3D"$3" - local tmpfile=3D"$infile.swp" =20 # sed append cmd: 'a\' + newline + text + newline cmd=3D"$(printf "a\\%b$insert" "\n")" =20 - sed -E -e "/$anchor/$cmd" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + # We don't really need a backup file, but in-place editing with backup + # skipped is not portable due to different implementations parsing + # arguments in incompatible manners. + # Create a backup file anyway to ensure portability. The file will be + # deleted on exit. + sed -E -i.swp -e "/$anchor/$cmd" "$infile" } =20 txt_subst() { local before=3D"$1" local after=3D"$2" local infile=3D"$3" - local tmpfile=3D"$infile.swp" =20 - sed -E -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmp= file" - # replace original file with the edited one - mv "$tmpfile" "$infile" + sed -E -i.swp -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" } =20 txt_delete() { local text=3D"$1" local infile=3D"$2" - local tmpfile=3D"$infile.swp" =20 - sed -E -e "/$text/d" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + sed -E -i.swp -e "/$text/d" "$infile" } =20 set_var() { @@ -142,6 +138,8 @@ if [ "$1" =3D "" ] ; then usage fi =20 +trap 'rm -f "$FN.swp"' EXIT + MUNGE_CASE=3Dyes while [ "$1" !=3D "" ] ; do CMD=3D"$1" --=20 2.53.0