tcl expert needed

Joshua Root jmr at macports.org
Thu May 31 19:01:03 PDT 2012


On 2012-6-1 10:21 , Bjarne D Mathiesen wrote:
> I've got the following piece of tcl script :
> 
> +++ script start +++
> proc filesys dirPath {
>     try {
>         foreach filePath [glob -directory ${dirPath} *] {
>             ui_msg "[file size ${filePath}] :: ${filePath}"
>             if { [file isdirectory ${filePath}] } {
>                 filesys ${filePath}
>             }
>         }
>     } finally {
>     }
> }
> 
> filesys "${filespath}/install"
> +++ script end +++

The try command is not standard Tcl, it's defined in
base/src/macports1.0/macports_util.tcl.

> What I'm trying to do, is walk recursively through a file system and
> make some action based upon wheher the /filePath/ is a dir or a normal
> file. It works perfectly - untill it reaches an empty dir and I get this
> error :
> 
> Error: Unable to open port: no files matched glob pattern "*"

Use glob -nocomplain if you don't want it to throw an error when nothing
matches. See 'man n glob'.

> What's bugging me is why the /try/ doesn't catch the error and ignores
> it.

You don't specify a catch block, so I guess it's probably assuming you
want the equivalent of a blank one?

- Josh


More information about the macports-dev mailing list