TIP 601: remove home folder shortcuts "~/" and "~user/" from file commands

Bounty program for improvements to Tcl and certain Tcl packages.
Author:         Harald Oehlmann <[email protected]>
State:          Draft
Type:           Project
Vote:           Pending
Tcl-Version:    9.0


A user home folder is inserted, if a file path starts with "~". This proposal is to remove this functionality.


A file name: "~abc.txt" is interpreted as the home folder of user "abc.txt". This results in an error message, even if the file exists.

This mimic may be helpful in an interactive shell, but makes access to files starting with "~" quite difficult. The file name must be prefixed by "./", if it is in the beginning of a file path.

The required code for file handling for files from foreign sources is:

if {[string match ~* $path]} {
    set path "./$path"

And the other way around on file output.


Remove the special handling of "~" from TCL file commands.

If it is used somewhere, replace it by a construction like "$env(HOME)/".


clt thread

Please refer to the CLT thread titled "User does not exists when file name start with ~" and started 2021-05-06 10:13

Some highlights:

broken code to fixed by this TIP

open [lindex $argv 0] ;


foreach fn [glob *] { open $fn } ;

the latter is especially puzzling, once you have a file starting with ~ in the directory, it suddenly fails.

Compatibility remark

And, the ~ breakage appears in the first run of an old script in a future v9 interpreter (file not found error) while the hidden latent data dependent bug is just waiting to bite someday.

Comment by Don Porter

This is a much deeper issue than either that draft TIP or the posts here have uncovered. The VFS layer has a problem not only with paths beginning with '~', but with all paths that have a prefix that can be claimed by a mounted Tcl_Filesystem. The same ./ prefixing has to be applied to workaround implications of this unfortunate design. A related matter is that prefixes and patterns that determine [file system] assignments are not accomplished by a registration, but by a round-robin game of hot potato. The design flaws are large and deep. A good solution is a pretty major rewrite. This isn't a quick fix.

Sometimes I think a good partial solution would be a rewrite that replaced all the conditional branches that implement the ~ translation pervasively in the VFS implementation, with a different strategy that made ~ translation available only through a separately mounted Tcl_Filesystem that claimed the path names matching ~*. In that revised strategy, more scripts and apps would have the option of unmounting that Tcl_Filesystem to disable the feature.

Some history and additional information in ticket


and probably other tickets I cannot find quickly now.


Here is the wiki page dedicated to this issue:



ToDo - volunteers ?


No compatibility, as targeting TCL9.


This document has been placed in the public domain.