[prev] [thread] [next] [Date index for 2004/09/16]
This is a multi-part message in MIME format. --------------010305090906000401050409 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, I've found a couple of edge case bugs in ttree and attach a patch to fix. 1) When the first match is a file to copy rather than to process and the parent target directory needs be created, ttree fails silently. A subsequent call to template->process would use mkpath and correctly make the parent and current sub. Patch changes use of mkdir to mkpath and fails fatally I think this was raised by Simon here :- http://lists.template-toolkit.org/pipermail/templates/2004-January/005582.html 2) When copying a file the $check variable is only locally set within the file matching loop and is set back to undef by perl on exiting the loop. When $check is used to report the matched regex it has no value. Patch sets $copy_file to be the value of the matched regex and uses this when reporting. I've also put a last in the loop if it matches. 3) I was finding that with 1) above it was going on to report a correct file copy but actually failing silently on the copy because the dir didn't exist, so I've moved the file correctly copied report to after the copy and fatally failed the copy. and finally thanks for Template Toolkit, it makes my job a hundred times easier :-) regards, Paul. --------------010305090906000401050409 Content-Type: text/plain; name="ttree.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ttree.patch.txt" --- /usr/bin/ttree 2004-09-16 15:16:07.000000000 +0100 +++ /data/sandbox/paulo/ttree 2004-09-16 15:14:50.000000000 +0100 @@ -263,10 +263,9 @@ # create target directory if required $target = "$destdir/$path"; unless (-d $target || $dryrun) { - mkdir $target, $mode || do { - warn "mkdir ($target): $!\n"; - next; - }; + mkpath $target, $mode or + die "Could not mkpath ($target): $!\n"; + # commented out by abw on 2000/12/04 - seems to raise a warning? # chown($uid, $gid, $target) || warn "chown($target): $!\n"; printf " + %-32s (created target directory)\n", $path @@ -324,7 +323,8 @@ # check against copy list foreach $check (@$copy) { if ($filename =~ /$check/) { - $copy_file = 1; + $copy_file = $check; + last; } } @@ -354,17 +354,21 @@ # check against copy list if ($copy_file) { - printf " > %-32s (copied, matches /$check/)\n", $file - if $verbose; unless ($dryrun) { - copy($absfile, $dest); + copy($absfile, $dest) or die "Could not copy + ($absfile to $dest) : $!\n"; + if ($preserve) { chown($uid, $gid, $dest) || warn "chown($dest): $!\n"; chmod($mode, $dest) || warn "chmod($dest): $!\n"; } } + + printf " > %-32s (copied, matches /$copy_file/)\n", $file + if $verbose; + return; } --------------010305090906000401050409-- _______________________________________________ templates mailing list templates@xxxxxxxxxxxxxxxx.xxx http://lists.template-toolkit.org/mailman/listinfo/templates
|
[Templates] a couple of minor bugs in ttree - patch attached
|
|
Re: [Templates] a couple of minor bugs in ttree - patch attached
|
Generated at 08:56 on 15 Mar 2005 by mariachi v0.52