TCL: Recursively search subdirectories to source all .tcl files

后端 未结 7 2073
独厮守ぢ
独厮守ぢ 2021-02-14 09:33

I have a main TCL proc that sources tons of other tcl procs in other folders and subsequent subdirectories. For example, in the main proc it has:

source $basepa         


        
7条回答
  •  北恋
    北恋 (楼主)
    2021-02-14 10:31

    Perhaps a little more platform independent and using builtins commands instead of piping to a process:

    foreach script [glob [file join $basepath folderA *.tcl]] {
      source $script
    }
    

    Repeat for folderB.

    If you have more stringent selection criteria, and don't worry about running on any other platforms, using find may be more flexible.

提交回复
热议问题