** Summary ** '''Quoting Hell''' is where you are when you've backed yourself into a corner, and now find yourself desperately escaping escape characters in your programming language, clinging to the hope that if you add another backslash or two, "it might work". some languages, this is the natural state of things. In Tcl, it happens when you're on the newbie learning curve and haven't yet come to the '''a-ha!''' moment about the [code is data%|%code/data] duality of Tcl values. You know you're in quoting hell when your Tcl code begins to look like [Perl]. Thankfully, unlike some other languages, quoting hell can be mostly avoided in Tcl. To learn how, digest the contents of [Tcl Quoting]! ** Examples ** '''Bad''' (from the [Macports file `macports.tcl`): ====== eval curl fetch $verboseflag {$source} {$tarpath} ====== '''Fixed''': ====== eval [list curl fetch $verboseflag $source $tarpath] ====== ---- '''Bad''' (from the [Macports file `macports.tcl`): ====== $workername eval set $opt \{[set $opt]\} ====== '''Fixed''': ====== $workername eval [list set $opt [set $opt]] ====== ---- '''Bad''' (from the [Macports file `macports.tcl`): ====== $workername eval set system_options($opt) \{[set $opt]\} ====== '''Fixed''': ====== $workername eval [list set system_options($opt) $opt] ====== ---- '''Bad''' (from the [MacPorts] file `macports.tcl`): ====== $workername eval "proc PortSystem \{version\} \{ \n\ package require port \$version \}" ====== '''Fixed''': ====== set script { proc PortSystem {version} { package require port ${version} } } set script [string map [list \${version} [list $version]] $script] $workername eval $script ====== <> Glossary