I think I have confirmed the bug. Consider this bash-script:
#! /bin/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 wrote:
Thank you for filing a new bug report with debbugs.gnu.org.
This is an automatically generated reply to let you know your message
has been received.
Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.
Your message has been sent to the package maintainer(s):
If you wish to submit further information on this problem, please
to report a problem with the Bug-tracking system.
------------------------------------------------------------------------------------------------------------
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
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 session in an Xfce4 desktop environment, fully updated:
My sed version:
sed (GNU sed) 4.9
Packaged by Debian
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software: 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,
Paolo Bonzini, Jim Meyering, and Assaf Gordon.
This sed program was built with SELinux support.
SELinux is disabled on this system.
-------------------------------------------------------------------------------------------------
Regards,
Vidar Hanto
Norway