GNU bug report logs -
#39978
Weird substitution of square brackets
Previous Next
Reported by: Evangelos Tsagkas <tsagkase <at> gmail.com>
Date: Sat, 7 Mar 2020 20:41:01 UTC
Severity: normal
Tags: notabug
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39978 in the body.
You can then email your comments to 39978 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#39978
; Package
sed
.
(Sat, 07 Mar 2020 20:41:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Evangelos Tsagkas <tsagkase <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Sat, 07 Mar 2020 20:41:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
$ echo "object[0])" | sed 's/[\]\[]/./g'
object[0])
$ echo "object[0])" | sed 's/[\]]/./g'
object[0])
$ echo "object[0])" | sed 's/[\[]/./g'
object.0])
$ echo "object[])" | sed 's/[\]\[]/./g'
object[])
$ echo "object[])" | sed 's/[\[\]]/./g'
object.)
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-sed <at> gnu.org
:
bug#39978
; Package
sed
.
(Sat, 07 Mar 2020 21:19:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
~$ sed --version
sed (GNU sed) 4.8
Copyright (C) 2020 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 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 without SELinux support.
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 <at> gnu.org>.
On Sat, Mar 7, 2020 at 10:17 PM Evangelos Tsagkas <tsagkase <at> gmail.com>
wrote:
> $ echo "object[0])" | sed 's/[\]\[]/./g'
> object[0])
> $ echo "object[0])" | sed 's/[\]]/./g'
> object[0])
> $ echo "object[0])" | sed 's/[\[]/./g'
> object.0])
> $ echo "object[])" | sed 's/[\]\[]/./g'
> object[])
> $ echo "object[])" | sed 's/[\[\]]/./g'
> object.)
>
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-sed <at> gnu.org
:
bug#39978
; Package
sed
.
(Sat, 07 Mar 2020 22:44:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 39978 <at> debbugs.gnu.org (full text, mbox):
tag 39978 notabug
close 39978
stop
Hello,
The commands you list below are correct and expected.
They follow POSIX's basic regular expression's "bracket expression"
behavior.
Note the following POSIX rules:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03
"9.3.3 - The <period>, <left-square-bracket>, and <backslash> shall be
special except when used in a bracket expression"
and
"9.3.5(1) - [...] The <right-square-bracket> ( ']' ) shall lose its
special meaning and represent itself in a bracket expression if it
occurs first in the list [...] Otherwise, it shall terminate the
bracket expression"
On Sat, Mar 07, 2020 at 10:17:28PM +0200, Evangelos Tsagkas wrote:
> $ echo "object[0])" | sed 's/[\]\[]/./g'
> object[0])
> $ echo "object[0])" | sed 's/[\]]/./g'
> object[0])
> $ echo "object[0])" | sed 's/[\[]/./g'
> object.0])
> $ echo "object[])" | sed 's/[\]\[]/./g'
> object[])
> $ echo "object[])" | sed 's/[\[\]]/./g'
> object.)
To illustrate:
# <backslash> in a bracket-expression is literal, not special
$ echo '\' | sed 's/[\]/X/'
# <left-square-bracket> inside a bracket-expression is literal, not special
$ echo '[' | sed 's/[[]/X/'
X
# Combine the above two rules, and even though this might be
# visually confusing, the bracket-expression only matches literal
# <backslash> and <left-square-bracket>, regardless of how many
# times they repeat in the bracket expression
$ echo '\[' | sed 's/[\[\[\[[\]/X/g'
XX
# Here <backslash>-<left-square-bracket> causes the
# <left-square-bracket> to become literal, not special:
$ echo '[' | sed 's/\[/X/'
# <right-square-bracket> appearing without a preceeding *special*
# <left-square-bracket> is also literal:
$ echo ']' | sed 's/]/X/'
X
# And thus:
$ echo '[]' | sed 's/\[]/X/'
X
I hope these explain how you got the above results.
As such, I'm closing this as "not a bug".
Discussion can continue by replying to this thread.
regards,
- assaf
Added tag(s) notabug.
Request was from
Assaf Gordon <assafgordon <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 07 Mar 2020 22:44:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
39978 <at> debbugs.gnu.org and Evangelos Tsagkas <tsagkase <at> gmail.com>
Request was from
Assaf Gordon <assafgordon <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 07 Mar 2020 22:44:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 05 Apr 2020 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 20 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.