[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String substitution bug
From: |
Zachary Santer |
Subject: |
Re: String substitution bug |
Date: |
Sun, 24 Nov 2024 12:39:06 -0500 |
On Sun, Nov 24, 2024 at 7:52 AM Martin D Kealey <martin@kurahaupo.gen.nz> wrote:
>
> When one already knows how it works, that's obvious, and it's hard to see
> how it could mean anything else.
>
> When one *doesn't *already know how it works, “using the syntax *[:class:]*”
> could just as easily mean using *:class:* inside *[…]*.
GNU sed errors out in this scenario:
$ var='this is a dog'
$ printf '%s\n' "${var//[[:blank:]]/S}"
thisSisSaSdog
$ printf '%s\n' "${var//[:blank:]/S}"
this is S dog
$ sed --regexp-extended --binary --expression='s/[[:blank:]]/S/g' <<< "${var}"
thisSisSaSdog
$ sed --regexp-extended --binary --expression='s/[:blank:]/S/g' <<< "${var}"
sed: character class syntax is [[:space:]], not [:space:]
$ printf '%s\n' "${?}"
4
Seems like a safe thing to do. Listing a : at both the beginning and
end of a bracket expression otherwise containing only letters would
serve no purpose.
- Re: String substitution bug, (continued)
- Re: String substitution bug, Martin D Kealey, 2024/11/24
- Re: String substitution bug, Oğuz, 2024/11/24
- Re: String substitution bug, Martin D Kealey, 2024/11/25
- Re: String substitution bug, Zachary Santer, 2024/11/25
- Re: String substitution bug, Martin D Kealey, 2024/11/25
- Re: String substitution bug, Greg Wooledge, 2024/11/24
- Re: String substitution bug, Andreas Kähäri, 2024/11/24
- Re: String substitution bug, Lawrence Velázquez, 2024/11/24
- Re: String substitution bug, Andreas Kähäri, 2024/11/25
- Re: String substitution bug, Martin D Kealey, 2024/11/25
- Re: String substitution bug,
Zachary Santer <=
- Re: String substitution bug, Andreas Kähäri, 2024/11/25
- Re: String substitution bug, Chet Ramey, 2024/11/25
- Re: String substitution bug, marcel.plch, 2024/11/25
- Re: String substitution bug, Lawrence Velázquez, 2024/11/25
- Re: String substitution bug, Lawrence Velázquez, 2024/11/25
- Re: String substitution bug, Chet Ramey, 2024/11/25
- Re: String substitution bug, Chet Ramey, 2024/11/25
Re: String substitution bug, Wiley Young, 2024/11/26