tcl catch syntax

Darren Weber dweber at macports.org
Mon May 18 15:48:54 PDT 2009


The following works in tclsh:

# Find all the example executables by parsing all the
# CMakeLists.txt files within the src Examples path
set exe {}
foreach f [exec find ${worksrcpath}/Examples -name "CMakeLists.txt"] {
    catch {exec -ignorestderr grep -e "ADD_EXECUTABLE" ${f} } results
options
    if {[dict get ${options} -code] == 0} {
        # Remove the string "ADD_EXECUTABLE(", with or without whitespace
        regsub -all "\[ \t\]*ADD_EXECUTABLE\[(\]\[ \t\]*" ${results} ""
results
        # Remove the string ".cxx)", with or without whitespace
        regsub -all ".cxx\[ \t\]*\[)\]" ${results} "" results
        set exe [concat ${exe} ${results}]
    }
}


The idea here is to parse a file tree to pull out all the lines in files
called "CMakeLists.txt" that contain the string "ADD_EXECUTABLES".  The bash
shell syntax using grep and sed is quite simple, but it get's messy when
translated to tcl.  Anyhow, it works in tclsh, but the destroot phase fails
with this error:

DEBUG: Executing proc-post-org.macports.destroot-destroot-2
Error: Target org.macports.destroot returned: wrong # args: should be "catch
command ?varName?"
Warning: the following items did not execute (for InsightToolkit):
org.macports.destroot
Error: Status 1 encountered during processing.


Here in the tcl 8.5 documentation, we have a different syntax that allows
the "option" variable:
http://www.tcl.tk/man/tcl8.5/TclCmd/catch.htm

Where is this error about tcl syntax generated?  Is this error tcl-version
specific?

Thanks, Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20090518/a301cea5/attachment.html>


More information about the macports-dev mailing list