Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-08-13
22:41 • Closed ticket [2834453fff]: Bug in handling "special" characters in [f... artifact: 524b593a11 user: dgp
04:57 • Ticket [2834453fff]: 4 changes artifact: 96e6f851d2 user: andreas_kupries
04:55 • Ticket [2834453fff]: 4 changes artifact: e3298aed33 user: andreas_kupries
04:55 • Add attachment OUT.txt to ticket [2834453fff] artifact: fbeb904eb7 user: andreas_kupries
04:54 • Ticket [2834453fff] Bug in handling "special" characters in file fun... artifact: 6d25cf4599 user: andreas_kupries
04:51 • Ticket [2834453fff]: 4 changes artifact: a3ecf59ac5 user: andreas_kupries
04:48 • Ticket [2834453fff]: 4 changes artifact: e73f780e8c user: dgp
04:43 • Ticket [2834453fff]: 4 changes artifact: 5663450b91 user: dgp
04:29 • Ticket [2834453fff]: 4 changes artifact: 7b54d287f9 user: dgp
04:29 • Ticket [2834453fff]: 4 changes artifact: 2db0c11199 user: dgp
03:53 • Ticket [2834453fff]: 4 changes artifact: 77221082c4 user: dgp
03:50 • Ticket [2834453fff]: 4 changes artifact: b24b092655 user: exgerhardr
02:21 • Ticket [2834453fff]: 4 changes artifact: 30e0819b12 user: dgp
01:53 • Ticket [2834453fff]: 4 changes artifact: 2c5e3c81ab user: dgp
2009-08-11
00:46 • Ticket [2834453fff]: 6 changes artifact: 23e099ad25 user: dgp
2009-08-09
20:07 • Ticket [2834453fff]: 4 changes artifact: e38b5ed8ad user: exgerhardr
19:57 • Ticket [2834453fff]: 4 changes artifact: 391e203658 user: exgerhardr
19:57 • Add attachment test_bug.tcl to ticket [2834453fff] artifact: 92b4e4f957 user: exgerhardr
12:57 • New ticket [2834453fff] Bug in handling "special" characters in file... artifact: 39cc249fbc user: exgerhardr

Bug in handling "special" characters in [file] function

Closed / Duplicate2834453fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-08-09 12:57:55
Tcl version: 8.5.7, also tested on 8.5.4, 8.5.5 with different behaviour
OS plattforms: Linux (ia32, amd64), Windows XP Professional
Problem Behaviour:
 1. Depending on Tcl-version the "special" characters ($,[,],\,~) are interpreted different and incorrect.
 2. Incorrect interpretation of "~" character, only meaningfull at beginning of a filename not on full path or inside of a filename. 
 3. Interpretation of "$,[,],\" in file and pathnames (violation of tcl 8.5 interpretation rule [11] Order of substitution).
 4. Using [file normalize] on files before [file ...] changes the behaviour (makes file "accessible" in 8.5.7, not in 8.5.4).
 5. All interpreted special characters are commonly used on Windows, other than on Unix (c-shell style) - see topic 4.
 6. File normalize is not possible on relative pathnames if name begins with "~" (correct according documented tilde interpretation).

Expected Behaviour:  
 1,3. Disabling influence of special characters "$,[,],\" in file command.
 2. Correct interpretation of "~" character (only at beginning of a filename). 
 4. Clean up  [file normalize] handling (EIAS violation).
 5,6. Add a new option which allows to ignore any interpretation, proposal: -nosubst.

Example: attached tcl test-script
Necessary environment for attached test script is a directory including 8 specific filenames:

*** File name list of dir /net/pub/WinXP/test
0: #\!home\!alina\!name#
1: $[filename].txt
2: $filename.txt
3: [filename].txt
4: filename[1].txt
5: file~name.txt
5: ./~$filename.txt
6: ./~[filename].txt
7: ./~filename.txt
exgerhardrplain2009-08-09 19:57:56
File Added - 338509: test_bug.tcl
exgerhardrplain2009-08-09 20:07:21
  Incorrect reference in 5.:
 5. All interpreted special characters are commonly used on Windows, other than on Unix (c-shell style) - see topic 4.
  should be changed to
 5. All interpreted special characters are commonly used on Windows, other than on Unix (c-shell style) - see topic 6.
dgpplain2009-08-11 00:46:15
I'm deep in another bug at the moment,
but then I'll examine this one.  Thanks
for the report.

If you don't see action here in 2 weeks,
ping with another comment.
dgpplain2009-08-13 01:53:20
Ok, I'm looking at this now, trying to break up
this extremely large and dense report into
some tasks that are of a size that can be tackled.
dgpplain2009-08-13 02:21:27
The first thing I see are a few more demonstration
examples of Bug 2806250.
exgerhardrplain2009-08-13 03:50:14
Additional comments to "special characters" and tilde expansion:  

In 8.5.7 $,[,] is interpreted correct but the interaction between tilde is "strange".

=== 1: File: /net/pub/WinXP/test/~[filename].txt ===
[file exist $f]-> 0 
[file type $f]-> could not read "/net/pub/WinXP/test/~[filename].txt": no such file or directory
[file type [file normalize $f]]-> file
[file type [subst -nocommands $f]]-> file

You see that [subst -nocommands $f] also circumvents the error like [file normalize $f].

Same with the file which begins with "~$":
=== 0: File: /net/pub/WinXP/test/~$filename.txt ===
[file exist $f]-> 0 
[file type $f]-> could not read "/net/pub/WinXP/test/~$filename.txt": no such file or directory
[file type [file normalize $f]]-> file
[file type [subst -novariables $f]]-> file

Also here [subst -novariables $f] circumvents the error.

Tilde expansion only is for "expanding" the beginning of the file and not inside of a file path and in csh also "quoting" is possibe (but not in tclsh).

gerhardr@nserver:/net/pub/WinXP/test>csh
nserver:/net/pub/WinXP/test> ls ~filename.txt
Unknown user: filename.txt.
nserver:/net/pub/WinXP/test> ls '~filename.txt'
~filename.txt
nserver:/net/pub/WinXP/test> cd ..
nserver:/net/pub/WinXP> ls /net/pub/WinXP/test/~filename.txt
/net/pub/WinXP/test/~filename.txt
dgpplain2009-08-13 03:53:45
No.  Please don't add more detail here.
My task at the moment is breaking it apart, 
not building it higher.
dgpplain2009-08-13 04:29:17
Next I see some examples of
Bug 2511011.
dgpplain2009-08-13 04:29:52
And the rest of the original report
adds up to a large sea of things
working as expected.
dgpplain2009-08-13 04:43:52
got another maintainer checking the
demo script on Windows in cases there's
some surprises there I haven't seen in
my linux testing.
dgpplain2009-08-13 04:48:40
and today's comment just demos
the same two bugs again.
andreas_kupriesplain2009-08-13 04:51:49
File Added - 338957: OUT.txt
andreas_kupriesplain2009-08-13 04:54:44
File Deleted - 338957:
andreas_kupriesplain2009-08-13 04:55:16
File Added - 338958: OUT.txt
andreas_kupriesplain2009-08-13 04:57:04
Attached a file OUT.txt with the results of running test_bug.tcl on Windows. Note the file 0 from the setup ('#\!home\!alina\!name#') could not be created, as it contains characters which are not allowed in filenames on that platform.
dgpplain2009-08-13 22:41:02
allow_comments - 1


thanks for that output, aku.  It shows
essentially the same symptoms as on
linux.  The key difference is that 
Bug 2806250 appears not to trigger (as much?)
on Windows  compared to linux.

Since all bugs demo'd by the submitted script
are already logged, closing this as a Dup.
Log in (anonymous is fine) to add a comment.

Attachments: