Tcl Source Code

View Ticket
Login
Ticket UUID: 2834453
Title: Bug in handling "special" characters in [file] function
Type: Bug Version: obsolete: 8.5.7
Submitter: exgerhardr Created on: 2009-08-09 12:57:55
Subsystem: 36. Pathname Management Assigned To: dgp
Priority: 7 High Severity:
Status: Closed Last Modified: 2009-08-13 22:41:02
Resolution: Duplicate Closed By: dgp
    Closed on: 2009-08-13 15:41:02
Description:
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
User Comments: dgp added on 2009-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.

andreas_kupries added on 2009-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.

andreas_kupries added on 2009-08-13 04:55:16:

File Added - 338958: OUT.txt

andreas_kupries added on 2009-08-13 04:54:44:

File Deleted - 338957:

andreas_kupries added on 2009-08-13 04:51:49:

File Added - 338957: OUT.txt

dgp added on 2009-08-13 04:48:40:
and today's comment just demos
the same two bugs again.

dgp added on 2009-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.

dgp added on 2009-08-13 04:29:52:
And the rest of the original report
adds up to a large sea of things
working as expected.

dgp added on 2009-08-13 04:29:17:
Next I see some examples of
Bug 2511011.

dgp added on 2009-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.

exgerhardr added on 2009-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

dgp added on 2009-08-13 02:21:27:
The first thing I see are a few more demonstration
examples of Bug 2806250.

dgp added on 2009-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.

dgp added on 2009-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.

exgerhardr added on 2009-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.

exgerhardr added on 2009-08-09 19:57:56:

File Added - 338509: test_bug.tcl

Attachments: