# some YART commands realized in Tcl:

#### RT_source ####
## looking for $file in $dirs and first level subdirs
## source it when found
proc RT_source {file {dirs ""} } {
    # looking in [pwd]:
    if [file exist $file] {source $file} {
	# else looking in the dirs:
	foreach d $dirs {
	    if [file exist $d/$file] { source $d/$file; return }
	    set sds [exec ls $d]
	    foreach sd $sds {
		if {[file isdir $d/$sd ] && [file exist $d/$sd/$file ]} {
		    source $d/$sd/$file; return 
		}
	    }
	}
	error "$file not found in: [pwd] $dirs!"
    }
}
