fs-traverse

Chris Pickel chpickel at stwing.upenn.edu
Tue Apr 24 08:24:00 PDT 2007


On 24 Apr, 2007, at 07:29, Randall Wood wrote:
> Can someone please provide a documented working example of using fs- 
> traverse to traverse a worksrcpath and perform a reinplace  
> operation on every Makefile?

I believe that would be:

fs-traverse file ${worksrcpath} {
   if [string match {/Makefile$} ${file}] {
     reinplace "s|/usr/local|${prefix}|g" ${file}
   }
}

Like "foreach", the first argument to fs-traverse is the name of the  
loop variable, and the second is the directory to traverse. It's  
almost like writing "foreach file [glob ${worksrcpath}/**/]", except  
that Tcl doesn't support zsh-style globbing.

Here's another fairly simple example you might use in destroot. It's  
is preferable to "eval file copy [glob ...]" in that you can take  
control of the file permissions if you need to, by adding further  
processing inside of the "file" case.

cd ${worksrcpath}
foreach top [glob *] {
   fs-traverse file ${top} {
     switch -exact [file type ${file}] {
       directory { xinstall -d -m 755 ${destination}/${file} }
       file { xinstall -m 644 ${file} ${destination}/${file} }
     }
   }
}

(there's a possibility "foreach... fs-traverse..." might in the  
future become "fs-traverse file [glob *]")


Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.macosforge.org/pipermail/macports-dev/attachments/20070424/39590bbb/PGP.bin


More information about the macports-dev mailing list