
string match fails for strings containing "["
Quote:
> Tcl 8.2.1 Bug: Generated by Scriptics' bug entry form at
> Submitted by: Jim Russell
> Synopsis: string match fails for strings containing "["
> ReproducibleScript:
> From tclsh8.2 command line I typed:
> set a {i[0]}
> set b $a
> string match $a $b
> ObservedBehavior:
> Setting b to the value of a should result in a successful match when comparing a to b.
This is erroneous, because the [] are special characters in glob
matching, so you are really asking:
string match i0 {i[0]}
If you want to avoid mistakes like this, use [string equal].
--
Jeffrey Hobbs The Tcl Guy
jeffrey.hobbs at scriptics.com Scriptics Corp.