modern Tcl and correct quoting
Lawrence Velázquez
larryv at macports.org
Wed Jun 12 19:17:10 PDT 2013
On Jun 12, 2013, at 6:18 PM, Poor Yorick <org.macosforge.lists.macports-dev at pooryorick.com> wrote:
> [eval] concatenates its arguments and passes them through the interpreter again
> to be parsed and executed as a script. This results in double substitution.
> Here's an example from the patch:
>
> $workername eval "package ifneeded $pkgName $pkgVers {$pkgLoadScript}"
>
> The first issue with this is that if, e.g., $pkgName contained a space, the
> constructed script would no longer be syntactically correct, as it would pass
> too many arguments to [package ifneeded]. The second issue is that simply
> putting braces around a substituted variable like $pkgLoadScript is not
> guaranteed to result in a well-formed single value. If $pkgLoadScript contains
> a left or right curly bracket, or if it ends in a backslash, the script will be
> corrupted. . The robust way to write the line above is like this:
>
> $workername eval [list package ifneeded $pkgName $pkgVers $pkgLoadScript]
>
> http://wiki.tcl.tk/1535 has more details.
Is there a material difference between using list here and doing something like this?
$workername eval {package ifneeded $pkgName $pkgVers $pkgLoadScript}
vq
More information about the macports-dev
mailing list