|
2016-04-25
| ||
| 15:49 | • Ticket [c7aa14ffdd] Linux C locale and filenames status still Closed with 5 ... artifact: af02851110 user: dgp | |
| 09:46 | • Closed ticket [c7aa14ffdd]. artifact: 2d6ffd0194 user: jan.nijtmans | |
| 09:45 | • Ticket [c7aa14ffdd]: 3 changes artifact: d603c8d4b5 user: jan.nijtmans | |
| 09:16 | • New ticket [c7aa14ffdd]. artifact: 2304fa4e87 user: anonymous | |
Linux C locale and filenames
Closed / Invalidc7aa14ffdd2507dd6bdd77baeec952676076f35bCreated 11 years agoUpdated 11 years ago
Descriptionplain2016-04-25 09:16:46
Tested on RHEL 6.5 (Linux 2.6.32-431.el6.x86_64) and Tcl 8.5.7.
From the Linux command line with LANG set to C I can create and manipulate the following file in a bash shell:
% echo "Test it" > 'test{'
% cat 'test{'
However if I start tclsh the following happens:
% set name [glob test*]
test\{
% set fh [open $name r]
couldn't open "test\{": no such file or directory
The encoding seems to have been defaulted to iso8859-1 but this seems to mean that certain files cannot be accessed reliably in Tcl.
% encoding system
iso8859-1
jan.nijtmansplain2016-04-25 09:45:29
The reason for this is that [glob] returns a list of files, not a filename, that's why the '\' needs to be inserted to form a valid Tcl list. So, your code should be (assuming you want to open the first file in the glob list):
% set name [lindex [glob test*] 1]
test{
% set fh [open $name r]
file3
jan.nijtmans Closed ticket [c7aa14ffdd].
[History diff]2016-04-25 09:46:04
dgpplain2016-04-25 15:49:02
Caution: Tcl list indices start with 0, not 1.
Log in (anonymous is fine) to add a comment.