reinplace loop
Ryan Schmidt
ryandesign at macports.org
Wed Jul 16 22:24:16 PDT 2014
On Jul 13, 2014, at 4:07 PM, Mark Brethen wrote:
> On Jul 13, 2014, at 3:28 PM, Jeremy Lavergne wrote:
>
>> On Jul 13, 2014, at 16:18, Mark Brethen wrote:
>>
>>> In need to reinplace the CMakeLists file in each subdirectory, replacing 'Mod/(subdirectory)' with 'lib/${name}/Mod/(subdirectory). How do you write a tcl loop to accomplish this? (Avoids creating a multitude of patch files.)
>>
>> I’d use fs-traverse, filtering to just the specific files you’re after.
>
> Will this traverse the subdirectories?
>
> fs-traverse file ${worksrcpath}/src/Mod {
> if [string match {/CMakeLists.txt$} ${file}] {
> reinplace "s| Mod/| lib/${name}/Mod/|g" ${file}
> }
> }
Yes, the purpose of the `fs-traverse` procedure is to traverse subdirectories. It's MacPorts' answer to the shell's `find` command.
Instead of "[string match {/CMakeLists.txt$} ${file}]", how about "{[file tail ${file}] == "CMakeLists.txt"}"?
More information about the macports-dev
mailing list