1#! /usr/bin/env tclkit 2 3# adjust mod times in dir trees to match most recent files inside 4 5if {$argv == ""} { 6 puts stderr "Usage: $argv0 dirs..." 7 exit 1 8} 9 10proc setdate {dir} { 11 set t 0 12 # do not traverse sym links, only do this for real dirs 13 if {[catch { file readlink $dir }]} { 14 set n [clock seconds] 15 foreach x [glob -nocomplain $dir/* $dir/.*] { 16 set m 0 17 if {[file isdir $x]} { 18 # 2007-04-07: also skip CVS and .svn dirs 19 switch -- [file tail $x] . - .. - CVS - .svn continue 20 set m [setdate $x] 21 } elseif {[file isfile $x]} { 22 set m [file mtime $x] 23 } 24 if {$m > $t && $m < $n + 900} { # allow some skew 25 set t $m 26 } 27 } 28 if {$t > 0 && $t != [file mtime $dir]} { 29 if {[catch { file mtime $dir $t } err]} { 30 puts "\n $dir: $err" 31 } else { 32 puts -nonewline + 33 } 34 } else { 35 puts -nonewline . 36 } 37 } 38 return $t 39} 40 41fconfigure stdout -buffering none 42 43foreach x $argv { 44 if {[catch { 45 setdate $x 46 puts "" 47 } err]} { 48 puts stderr "$x: $err" 49 } 50} 51