Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unexpected behavior: wrong file opened

0 views
Skip to first unread message

Vitaly Magerya

unread,
Dec 20, 2009, 5:37:30 PM12/20/09
to
Greetings, group. I've just run into some unexpected behavior with Tcl
8.5.8, and I ask for your help/advice on how to deal with it.

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?

Alexandre Ferrieux

unread,
Dec 20, 2009, 5:53:00 PM12/20/09
to

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

Vitaly Magerya

unread,
Dec 20, 2009, 6:01:39 PM12/20/09
to
On 2009-12-21 00:53, Alexandre Ferrieux wrote:
> On Dec 20, 11:37 pm, Vitaly Magerya <vmage...@gmail.com> wrote:
>> Greetings, group. I've just run into some unexpected behavior with Tcl
>> 8.5.8, and I ask for your help/advice on how to deal with it.
>>
>> 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]
>>
> 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.

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?

Alexandre Ferrieux

unread,
Dec 20, 2009, 6:09:47 PM12/20/09
to

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

Vitaly Magerya

unread,
Dec 20, 2009, 6:21:05 PM12/20/09
to
Alexandre Ferrieux wrote:
>> 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.

OK, I tried Tcl 8.6-beta1: it's the same as 8.5.8 on my machine (i.e.
seems broken).

Alexandre Ferrieux

unread,
Dec 20, 2009, 6:30:32 PM12/20/09
to

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

Vitaly Magerya

unread,
Dec 20, 2009, 7:09:21 PM12/20/09
to
Alexandre Ferrieux wrote:
>> 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).

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.

0 new messages