From unknown Sun Jun 15 10:54:13 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#77462 <77462@debbugs.gnu.org> To: bug#77462 <77462@debbugs.gnu.org> Subject: Status: "/s" instability? I think this is a bug. Reply-To: bug#77462 <77462@debbugs.gnu.org> Date: Sun, 15 Jun 2025 17:54:13 +0000 retitle 77462 "/s" instability? I think this is a bug. reassign 77462 sed submitter 77462 "gnudborgonly@s-epost.no" severity 77462 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 11:20:59 2025 Received: (at submit) by debbugs.gnu.org; 2 Apr 2025 15:20:59 +0000 Received: from localhost ([127.0.0.1]:58978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzzti-00010p-47 for submit@debbugs.gnu.org; Wed, 02 Apr 2025 11:20:59 -0400 Received: from lists.gnu.org ([2001:470:142::17]:50690) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tzyg8-0005rf-Ro for submit@debbugs.gnu.org; Wed, 02 Apr 2025 10:02:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tzyfp-0004al-Kn for bug-sed@gnu.org; Wed, 02 Apr 2025 10:02:34 -0400 Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tzyfh-0007ne-Oy for bug-sed@gnu.org; Wed, 02 Apr 2025 10:02:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=s-epost.no; s=ds202404; h=MIME-Version:Date:Content-Type:To:From:Subject:Message-ID:From: Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=zLkmCVKYIg2cgyfoZKK91r8tHmydZQ7tya4b4GX5Yb8=; b=r NPj6AjSm7+xXaf8lkondA5J2RbnrJ/ZX/jzduu1AHzXEu+eh4B9hmAtwKvo0cYW3pGQnkCtl5RvYu EM0WdALWEgddtIXX9qyAw13fSfhgh4xVuZBmGIBAG+P77EMDOBgc0J2rnhTQaExOLmliAmn0i8VQz ZPq3junoXq59ODszG5PxJ/N0oMPa36pLn+NQd0aJdqEpHNoRk8+2frjRDmmpeIdgQo4hPrklOffDN hIkkNtY9npgTjCJSs0VqvRaOXa2lYxc9fX9rDTtbz8z54kFuHMsLQiF//BY/Ou7hti5Gb8A/LDhsi 66fmoWodhi1hK+GbH0/xTNG6w8BaeGC/A==; Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) id 1tzyfX-00HDmX-Uk for bug-sed@gnu.org; Wed, 02 Apr 2025 16:02:16 +0200 Message-ID: <48f9f9d4282960b42004b894c2a1ffa7635be4b2.camel@s-epost.no> Subject: "/s" instability? I think this is a bug. From: "gnudborgonly@s-epost.no" To: bug-sed@gnu.org Content-Type: multipart/alternative; boundary="=-O/RG9alEVj+Uwhs+VvRm" Date: Wed, 02 Apr 2025 16:00:40 +0200 MIME-Version: 1.0 User-Agent: Evolution 3.46.4-2 Received-SPF: pass client-ip=2a01:5b40:0:3006::1; envelope-from=gnudborgonly@s-epost.no; helo=smtp.domeneshop.no X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 02 Apr 2025 11:20:56 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-O/RG9alEVj+Uwhs+VvRm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This seems to qualify as a bug: The sed version included in my Linux seems to be unstable when using the '\s' and/or '\S' regex extensions: Example: id@pc:~$ echo '[ subCA2 ]' | sed -n 's|^\[\s\+\([^\s]\+[0- 9]\+\)\s\+\]\s*$|\1|p' id@pc:~$ echo '[ subCA2 ]' | sed -n 's:^\[\s\+\([\S]\+[0- 9]\+\)\s\+\]\s*$:\1:p' id@pc:~$ echo '[ rootCA1 ]' | sed -n 's|^\[\s\+\([^\s]\+[0- 9]\+\)\s\+\]\s*$|\1|p' rootCA1 =20 If I replace '\s' with '[ \t]' (and '\S' with '[^ \t]') things work as expected: id@pc:~$ echo '[ subCA2 ]' | sed -n 's:^\[[ \t]\+\([^ \t]\+[0-9]\+\)[ \t]\+\][ \t]*$:\1:p' subCA2 id@pc:~$ echo '[ rootCA2 ]' | sed -n 's:^\[[ \t]\+\([^ \t]\+[0-9]\+\)[ \t]\+\][ \t]*$:\1:p' rootCA2 ----------------------------------------------------------------------- -------------------------- My Linux version:=20 Debian 12.10 as per 2025-04-02, terminal session in an Xfce4 desktop environment, fully updated:=20 My sed version: id@pc:~$ sed --version sed (GNU sed) 4.9 Packaged by Debian Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. =20 Written by Jay Fenlason, Tom Lord, Ken Pizzini, Paolo Bonzini, Jim Meyering, and Assaf Gordon. =20 This sed program was built with SELinux support. SELinux is disabled on this system. =20 GNU sed home page: . General help using GNU software: . E-mail bug reports to: . id@pc:~$=20 ----------------------------------------------------------------------- -------------------------- Regards, Vidar Hanto Norway --=-O/RG9alEVj+Uwhs+VvRm Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
This seems to qualify as a bug:
The sed version i= ncluded in my Linux seems to be unstable when using the '\s' and/or '\S' re= gex extensions:
Example:

id@pc:~$ echo '[ subCA2 ]' | sed -n = 's|^\[\s\+\([^\s]\+[0-9]\+\)\s\+\]\s*$|\1|p'
id@pc:~$ echo '[ subCA2 ]' | sed -n '= s:^\[\s\+\([\S]\+[0-9]\+\)\s\+\]\s*$:\1:p'
id@pc:~$ echo '[ rootCA1 ]' | sed -n 's= |^\[\s\+\([^\s]\+[0-9]\+\)\s\+\]\s*$|\1|p'
rootCA1

If I replace '\s' with '[ \t]' (and '\S' with '[^ \t]') = things work as expected:
id@pc:~$ echo '[ subCA2 ]' | sed -n 's:^\[[ \t]\+\([^ \t]\+[0-9]= \+\)[ \t]\+\][ \t]*$:\1:p'
subCA2
id@pc:~$ echo '[ rootCA2 ]' | sed -n 's:^\= [[ \t]\+\([^ \t]\+[0-9]\+\)[ \t]\+\][ \t]*$:\1:p'
rootCA2
=
------------------------------= -------------------------------------------------------------------
My Linux version:
Debian 12.10 as per 2025-04-02, terminal se= ssion in an Xfce4 desktop environment, fully updated:

=
My sed version:
id@pc:~$ sed --= version
sed (GNU sed) 4.9
Packaged by Deb= ian
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistrib= ute it.
There is NO WARRANTY, to the extent permitted by l= aw.

Written by Jay Fenlason, Tom Lor= d, Ken Pizzini,
Paolo Bonzini, Jim Meyering, and Assaf Gor= don.

This sed program was built with= SELinux support.
SELinux is disabled on this system.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E= -mail bug reports to: <bug-sed@gnu.or= g>.
id@pc:~$
--------------------= ---------------------------------------------------------------------------= --

Regards,
Vidar Hanto
Norway

--=-O/RG9alEVj+Uwhs+VvRm-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 16:07:36 2025 Received: (at 77462) by debbugs.gnu.org; 2 Apr 2025 20:07:36 +0000 Received: from localhost ([127.0.0.1]:59661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u04N6-0000WQ-H9 for submit@debbugs.gnu.org; Wed, 02 Apr 2025 16:07:36 -0400 Received: from mail-pl1-f182.google.com ([209.85.214.182]:46159) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u04N3-0000W1-MB for 77462@debbugs.gnu.org; Wed, 02 Apr 2025 16:07:35 -0400 Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-226185948ffso2385915ad.0 for <77462@debbugs.gnu.org>; Wed, 02 Apr 2025 13:07:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743624447; x=1744229247; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zPzTwYJDd87be/y72qFwju8jE0Sa2Txqa56lk66BrlM=; b=pefIxjhDQdVQH0YCMqROW8o7KRjnqi0RpU4NTF/KUURD/rKe8xX79kWSoSa2AEI4Rm CHJZoa6sU4YU6UD2sxai3OZEdjLSAWmfYvc/gmsCPEJu2mXQiqjLVSzGt1wUNy2rrxQZ NOr9/nJ7ea3Q/QwxEE6nU5fw0/Tqs5wQhT3cjU6vSzOyAzYhS7CnnHZAWiKXzmB16VCA LjqZdPgSm3yeTWAZx4JytfP3HCDOGHACa6VodWADxUUENO0R+d51QtpAKUcpshD6zgHx 7c8iDrS/sAI/UvrowexoSlYGQzV2y0QWGiC2Y+IeYF/JeJTg8J7B55bllX8rpjAqOkXU 0gag== X-Gm-Message-State: AOJu0Yz7PX1R4h0QNRmkZudBD09dn0uuba7bHks06gRU4AwQXtfabgrl P+5848Jg2ziAxLKkrrEcpIc3m2XMKUpVUXyoFoFLaZlZ/X37Xq9vh+0pMjyRSvIL0HuBSh+m27E v3U30Jxnw9bCJv5BxWdvHjFBnBAI= X-Gm-Gg: ASbGncvLmVYNsct+6zK7Bob5U0C1gqez8j14ekPznF5IVOHXd+7Rosfu1Gl+P1gTBJ7 +ZOWYAv2kNdj/+LuOkYSfm1fYkqknkHUbXh1Ob180QhD+iipgxWA4yfA7lB/cMKdMMmrj5t0Cnh Abe1GCluJtKGX+w0nTluXec7sjjcD0zlCzzehJWr9Vaw== X-Google-Smtp-Source: AGHT+IE/fd+N1N9QE0X9HCuNfGFbr46rExu8CmuWwMDX8lrCM0Z/k2GbzfzHtZjZaZOs++s/FsxQlGy9v061nOCVcek= X-Received: by 2002:a17:903:1aaf:b0:223:3ef1:a30a with SMTP id d9443c01a7336-2296c861ca6mr50196465ad.45.1743624447156; Wed, 02 Apr 2025 13:07:27 -0700 (PDT) MIME-Version: 1.0 References: <48f9f9d4282960b42004b894c2a1ffa7635be4b2.camel@s-epost.no> In-Reply-To: <48f9f9d4282960b42004b894c2a1ffa7635be4b2.camel@s-epost.no> From: Jim Meyering Date: Wed, 2 Apr 2025 13:07:14 -0700 X-Gm-Features: AQ5f1Jox3XcFXa2XwBDDeqYOoXGJv7OoDJD6R9a0SQp7fPX_E93JoXW5gaA2D64 Message-ID: Subject: Re: bug#77462: "/s" instability? I think this is a bug. To: "gnudborgonly@s-epost.no" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77462 Cc: 77462@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Wed, Apr 2, 2025 at 8:41=E2=80=AFAM gnudborgonly@s-epost.no via wrote: > This seems to qualify as a bug: Thanks for the report. You can fix your usage by not putting "[...]" around those uses of "\s" or = "\S". > The sed version included in my Linux seems to be unstable when using > the '\s' and/or '\S' regex extensions: > > Example: > > id@pc:~$ echo '[ subCA2 ]' | sed -n 's|^\[\s\+\([^\s]\+[0-9]\+\)\s\+\]= \s*$|\1|p' > id@pc:~$ echo '[ subCA2 ]' | sed -n 's:^\[\s\+\([\S]\+[0-9]\+\)\s\+\]\= s*$:\1:p' Drop the square brackets and it works. I.e., change the latter to this: $ echo '[ subCA2 ]' | sed -n 's:^\[\s\+\(\S\+[0-9]\+\)\s\+\]\s*$:\1:p' subCA2 Or better still, use sed's -E option to make the regular expression more readable, eliding **six** backslashes: echo '[ subCA2 ]' | sed -nE 's:^\[\s+(\S+[0-9]+)\s+\]\s*$:\1:p' I admit this is an unpleasant irregularity about GNU sed's "\S" extension, since it's different from how things work in PCRE. This is one of the reasons I urge people use Perl instead of sed (another is because PCRE lets you use "\d" and non-greedy modifiers like "\S+?" below): $ echo '[ subCA2 ]' | perl -nle 'm{^\[\s+(\S+?\d+)\s+\]\s*$} and print $1= ' subCA2 Searching Sed's sources/docs for references to \S and \s vs ranges, I found no trace, but did see this 4.1 NEWS entry: * removed documentation for \s and \S which worked incorrectly I'll leave this bug report open, because this is a wart that needs to be documented. From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 16:31:21 2025 Received: (at 77462) by debbugs.gnu.org; 2 Apr 2025 20:31:21 +0000 Received: from localhost ([127.0.0.1]:59705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u04k4-0001f0-BK for submit@debbugs.gnu.org; Wed, 02 Apr 2025 16:31:21 -0400 Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]:50316) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u04Xm-0000zr-Jw for 77462@debbugs.gnu.org; Wed, 02 Apr 2025 16:18:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=s-epost.no; s=ds202404; h=MIME-Version:Date:Content-Type:References:In-Reply-To:To:From: Subject:Message-ID:From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=exFLSAGc1V8/SVCYUTn7d7fdsZNMtG6VZt3fYBU1dhM=; b=dt+CxoZlB366qZoarBYDnS6yiY +RacuwKE09By8sYqC8UYJAAVAIdTpA6EYMF2Z31mAAqr/eeBpeYDZ15xx6Q890ft02DFj8bIzG5NM fwEImKoyvKZmQHU7uIOLf6mphy6p5B5WU+yCv4HCF6yhou5qkzAPjga5rM9nHlHgv/9k08qlgJiRt I0BJVP/QRkMdc94sPidRGWszTEHBnnT5vC644Th8JJ2yQIRjq6uG44LCoqKKOImeQkZ/3JPXvQibi zEIN6nEA8V05QA4qOHsZFj5XaWFupEO5hShxkdhnVDpRCOpwyy3y05OPZi+aVHzGp4OMu2xgru/C2 /TiJ7Jwg==; Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) id 1u04Xb-001XZO-FJ for 77462@debbugs.gnu.org; Wed, 02 Apr 2025 22:18:27 +0200 Message-ID: <7f9f3c361d5f5e5aa12c036c1f9fb19a16e39456.camel@s-epost.no> Subject: Re: bug#77462: Acknowledgement ("\s" instability? I think this is a bug.) From: "gnudborgonly@s-epost.no" To: 77462@debbugs.gnu.org In-Reply-To: References: <48f9f9d4282960b42004b894c2a1ffa7635be4b2.camel@s-epost.no> Content-Type: multipart/alternative; boundary="=-a4/rKwd/9UHG1bQB30Lo" Date: Wed, 02 Apr 2025 22:18:26 +0200 MIME-Version: 1.0 User-Agent: Evolution 3.46.4-2 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 77462 X-Mailman-Approved-At: Wed, 02 Apr 2025 16:31:13 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-a4/rKwd/9UHG1bQB30Lo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I think I have confirmed the bug. Consider this bash-script: #! /bin/bash =20 for x in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z; do =C2=A0 echo "[ ${x}XXtxt1 ]" | sed -n 's|^\[\s\+\([^\s]\+[0- 9]\+\)\s\+\]\s*$|\1|p' done =20 sed is printing a result in all cases, except when the 's' is starting the text that is captured in the sed-script. Regards, Vidar Hanto Norway ----------------------------------------------------------------------- ---------------------------------------- On Wed, 2025-04-02 at 15:21 +0000, GNU bug Tracking System wrote: > Thank you for filing a new bug report with debbugs.gnu.org. >=20 > This is an automatically generated reply to let you know your message > has been received. >=20 > Your message is being forwarded to the package maintainers and other > interested parties for their attention; they will reply in due > course. >=20 > Your message has been sent to the package maintainer(s): > =C2=A0bug-sed@gnu.org >=20 > If you wish to submit further information on this problem, please > send it to 77462@debbugs.gnu.org. >=20 > Please do not send mail to help-debbugs@gnu.org=C2=A0unless you wish > to report a problem with the Bug-tracking system. >=20 ----------------------------------------------------------------------- ------------------------------------- This seems to qualify as a bug: The sed version included in my Linux seems to be unstable when using the '\s' and/or '\S' regex extensions: Example: id@pc:~$ echo '[ subCA2 ]' | sed -n 's|^\[\s\+\([^\s]\+[0- 9]\+\)\s\+\]\s*$|\1|p' id@pc:~$ echo '[ subCA2 ]' | sed -n 's:^\[\s\+\([\S]\+[0- 9]\+\)\s\+\]\s*$:\1:p' id@pc:~$ echo '[ rootCA1 ]' | sed -n 's|^\[\s\+\([^\s]\+[0- 9]\+\)\s\+\]\s*$|\1|p' rootCA1 =20 If I replace '\s' with '[ \t]' (and '\S' with '[^ \t]') things work as expected: id@pc:~$ echo '[ subCA2 ]' | sed -n 's:^\[[ \t]\+\([^ \t]\+[0-9]\+\)[ \t]\+\][ \t]*$:\1:p' subCA2 id@pc:~$ echo '[ rootCA2 ]' | sed -n 's:^\[[ \t]\+\([^ \t]\+[0-9]\+\)[ \t]\+\][ \t]*$:\1:p' rootCA2 ----------------------------------------------------------------------- -------------------------- My Linux version:=C2=A0 Debian 12.10 as per 2025-04-02, terminal session in an Xfce4 desktop environment, fully updated:=C2=A0 My sed version: id@pc:~$ sed --version sed (GNU sed) 4.9 Packaged by Debian Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. =20 Written by Jay Fenlason, Tom Lord, Ken Pizzini, Paolo Bonzini, Jim Meyering, and Assaf Gordon. =20 This sed program was built with SELinux support. SELinux is disabled on this system. =20 GNU sed home page: . General help using GNU software: . E-mail bug reports to: . id@pc:~$=C2=A0 ----------------------------------------------------------------------- -------------------------- Regards, Vidar Hanto Norway --=-a4/rKwd/9UHG1bQB30Lo Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
I think I have confirmed the bug. Consider th= is bash-script:

#! /bi= n/bash

for x in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z= a b c d e f g h i j k l m n o p q r s t u v w x y z; do
  echo "[ ${x}XXtxt1 ]" | sed -n 's|^\[\s\+\([^\s]= \+[0-9]\+\)\s\+\]\s*$|\1|p'
done

sed is printing a result= in all cases, except when the 's' is starting the text that is captured in= the sed-script.

Regards,
Vidar Hanto
Norway

-----------------------------------= ---------------------------------------------------------------------------= -
On Wed, 2025-04-02 at 15:21 +0000, GNU bug Tracking System wrot= e:
Thank you for filing a new bug repo= rt with debbugs.gnu.org.

This is an automatica= lly generated reply to let you know your message
has been rec= eived.

Your message is being forwarded to the = package maintainers and other
interested parties for their at= tention; they will reply in due course.

Your m= essage has been sent to the package maintainer(s):

=
If you wish to submit further information on this problem, please
<= /div>

Please do not send mail to help-debbugs@gnu.org unless you= wish
to report a problem with the Bug-tracking system.

--------------------------------------= ----------------------------------------------------------------------

This seems to qualify as a bug:

The sed version inclu= ded in my Linux seems to be unstable when using the '\s' and/or '\S' regex = extensions:

Example:

id@pc:~$ ech= o '[ subCA2 ]' | sed -n 's|^\[\s\+\([^\s]\+[0-9]\+\)\s\+\]\s*$|\1|p'=
id@pc:~$ echo '[ subCA2 ]' | sed -n 's:^\[\s\+\([\S]\+[0-9]\= +\)\s\+\]\s*$:\1:p'
id@pc:~$ echo '[ rootCA1 ]' | sed = -n 's|^\[\s\+\([^\s]\+[0-9]\+\)\s\+\]\s*$|\1|p'
rootCA1

If I replace '\s' with '[ \t]' (and '\S' with '[^= \t]') things work as expected:
id@pc:~$ echo '[ subCA2 ]' | = sed -n 's:^\[[ \t]\+\([^ \t]\+[0-9]\+\)[ \t]\+\][ \t]*$:\1:p'
<= div style=3D"unicode-bidi: plaintext; font-family: Sans; font-size: 12px; f= ont-style: normal; font-variant-caps: normal; font-weight: 400; letter-spac= ing: normal; orphans: auto; text-align: start; text-indent: 0px; text-trans= form: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-t= ap-highlight-color: rgba(0, 0, 0, 0.4); -webkit-text-stroke-width: 0px; tex= t-decoration: none; caret-color: rgb(46, 52, 54); color: rgb(46, 52, 54); m= argin-left: 3ch;">subCA2
= id@pc:~$ echo '[ rootCA2 ]' | sed -n 's:^\[[ \t]\+\([^ \t= ]\+[0-9]\+\)[ \t]\+\][ \t]*$:\1:p'
rootCA2

---------------= ---------------------------------------------------------------------------= -------
My Linux version: 
 <= /div>
=
My sed version:
id@pc= :~$ sed --version
sed (GNU sed) 4.9
Packaged by Debian
<= font face=3D"Courier New, Courier, monospace">Copyright (C) 2022 Free Softw= are Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
<= div style=3D"unicode-bidi: plaintext; caret-color: rgb(0, 0, 0); color: rgb= (0, 0, 0); font-family: Sans; font-size: 12px; font-style: normal; font-var= iant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto;= text-align: start; text-indent: 0px; text-transform: none; white-space: no= rmal; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0,= 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none; margin-= left: 3ch;">This is free sof= tware: you are free to change and redistribute it.
There is NO WARRANTY, to = the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,=
Pa= olo Bonzini, Jim Meyering, and Assaf Gordon.

This sed program was built with= SELinux support.
SELinux is disabled on this system.

GNU sed home page: <= https://www.gnu.org/software/sed/>.
Genera= l help using GNU software: <https://www.gnu.org/gethe= lp/>.
E-mail bug reports to: <bug-sed@gnu.org>.
<= div style=3D"unicode-bidi: plaintext; caret-color: rgb(0, 0, 0); color: rgb= (0, 0, 0); font-family: Sans; font-size: 12px; font-style: normal; font-var= iant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto;= text-align: start; text-indent: 0px; text-transform: none; white-space: no= rmal; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0,= 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none; margin-= left: 3ch;">id@pc:~$ 
----------------------------------= ---------------------------------------------------------------

<= div style=3D"unicode-bidi: plaintext; caret-color: rgb(0, 0, 0); color: rgb= (0, 0, 0); font-family: Sans; font-size: 12px; font-style: normal; font-var= iant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto;= text-align: start; text-indent: 0px; text-transform: none; white-space: no= rmal; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0,= 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none;">=
Regards,
Vidar Hanto
Norway


--=-a4/rKwd/9UHG1bQB30Lo--