Skip to content
Tcl Source Code View Ticket
Login

View Ticket

clear ~ cache when ::env(HOME) changes

Closed / Fixed535621ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2002-03-27 08:00:10
The normalizedPath cached inside a "pathPtr" object
needs to be invalidated when the raw string form
of the path starts with ~ and the value of ::env(HOME)
changes.  Here's a demo session of the problem:

First, the working code in 8.3:

% info patch
8.3.4
% proc test {} {
    set ::env(HOME) /home/dgp
    puts "Parent of $::env(HOME)"
    catch {file dirname ~} parent
    puts "is $parent"
    set ::env(HOME) /usr/local/src
    puts "Parent of $::env(HOME)"
    catch {file dirname ~} parent
    puts "is $parent"
}
% test
Parent of /home/dgp
is /home
Parent of /usr/local/src
is /usr/local

Compare with the broken 8.4:

% info patch
8.4a5
% proc test {} {
    set ::env(HOME) /home/dgp
    puts "Parent of $::env(HOME)"
    catch {file dirname ~} parent
    puts "is $parent"
    set ::env(HOME) /usr/local/src
    puts "Parent of $::env(HOME)"
    catch {file dirname ~} parent
% test
Parent of /home/dgp
is /home
Parent of /usr/local/src
is /home
nobodyplain2002-03-27 16:59:18
Logged In: NO 

Ah!  Interesting -- I didn't think of that.  Fortunately 
there's a method in place to invalidate the cache, so it 
just needs calling when env(HOME) changes.  Calling

Tcl_FSMountsChanged(NULL);

will do the trick.  Unfortunately I'm travelling for the 
next week so can't make a patch.
vincentdarley Closed ticket [535621ffff]. [History diff]2002-04-03 15:35:59
vincentdarleyplain2002-04-03 15:36:00
Logged In: YES 
user_id=32170

Applying patch to fix this problem.
vincentdarleyplain2002-04-03 15:40:58
Logged In: YES 
user_id=32170

We should also add a test to fileSystem.test to check the 
fixed behaviour.

Vince.
dgpplain2002-04-03 21:14:41
Logged In: YES 
user_id=80530

Actually it was a failure in test cmdAH-8.44 that
lead me to the bug.

A more reliable test would be a good idea though.
cmdAH-8.44 only started failing after I updated
the tcltest package, and only when doing

   make test TESTFLAGS="-singleproc 1"

According to that test, and the test case in the
report, the fix is effective.
Log in (anonymous is fine) to add a comment.