Here's a stripped down code snippet:
set root somedir
exec rm -rf $root
exec touch $root/x.y
file normalize anything
foreach fn [glob $root/x.y] {
set ofn [file rootname $fn]
set fl [open $ofn {WRONLY CREAT}]
puts $fl "something"
close $fl
}
puts [exec ls $root]
This code should put "something" into somedir/x, and should print x and
x.y. But when I run it in Tcl 8.5.8 on FreeBSD 7-STABLE, it instead puts
"something" into somedir/x.y, and prints x.y; somedir/x is not created,
even though $ofn is somedir/x.
Running the same snippet in Tcl 8.4.19 works as expected. Removing the
void "file normalize", replacing glob with it's value, or removing
foreach loop also makes it work as I expect.
So, is this a known issue? Unfortunately I could not find anything in
the bug tracker (or google). Can any of you reproduce it in other
environments? Any advice on how to deal with it? Using other Tcl builds
is undesirable for me (I will try 8.6 beta build though), and changing
parts I mentioned is also problematic, since it's all part of a bigger
piece of code (I really need file normalize and foreach/glob). Finally,
any insight into what causes this behavior?
Hm, maybe a red herring, but the above code doesn't create the
'somedir' directory itself. So the only thing that Tcl can do is raise
an error on glob. Maybe you caught the error and got confused by
effects of previous tests ?
Anyway, FWIW, adding [file mkdir $root] after the rm -rf, I don't see
any strange behavior on Windows+mingw.
-Alex
Oh, sorry. I missed one line when typed the message; the snippet should
actually be:
set root somedir
exec rm -rf $root
exec mkdir -p $root
exec touch $root/x.y
[...]
> Anyway, FWIW, adding [file mkdir $root] after the rm -rf, I don't see
> any strange behavior on Windows+mingw.
Thanks for checking that out. Do you use Tcl 8.5?
Yes, 8.5 HEAD. No FreeBSD at hand, sorry.
I'd suspect an issue with the internal representation of paths. ISTR
similar bugs detected and corrected this year, probably on 8.6. So
trying 8.6 now looks like a good idea, to narrow the investigation a
bit.
-Alex
OK, I tried Tcl 8.6-beta1: it's the same as 8.5.8 on my machine (i.e.
seems broken).
Interesting. While the path intrep caching is admittedly complex, the
OS-dependency is a bit surprising. Will try on a linux asap (unless
you beat me to it).
I was about to suggest a link with bug 1972879 at
https://sourceforge.net/tracker/?func=detail&aid=1972879&group_id=10894&atid=110894
but it was fixed before 8.6b1. Or maybe it is another facet of a
deeper problem...
In any case, a bug report seems in order now :}
-Alex
It also fails on another box with FreeBSD/amd64 8.0-RC2 and Tcl 8.5.8,
but works on yet another Windows XP with ActiveTcl (8.5.8).
I'll be able to check Mac OS X and some Linux tomorrow.
> I was about to suggest a link with bug 1972879 at
>
> https://sourceforge.net/tracker/?func=detail&aid=1972879&group_id=10894&atid=110894
>
> but it was fixed before 8.6b1. Or maybe it is another facet of a
> deeper problem...
>
> In any case, a bug report seems in order now :}
I wanted someone else to reproduce this, but since two of my boxes show
the same behavior, I'll file a bug report in about 10 hours (it's past
the midnight in my timezone).
In the mean while I'll try to workaround it somehow in my code.