bug-bash
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]