Skip to content
Tcl Source Code View Ticket
Login

View Ticket

unexpected result for "file normalize"

Closed / Fixedf34cf83dd0150cbbea33469d70a6a400559979c1Created 10 years agoUpdated 10 years ago
Descriptionplain2017-04-25 09:48:09
Two slashes in paths are only sometimes reduced to a single slash. This inconsistent behavior contradicts the aim that "file normalize" returns 'the “standard” format for the native platform'. 

This is seen at least with tcl 8.6.6 and Tcl 8.7a0 on MacOS X and Linux.

   % file normalize //foo
   //foo
   % file normalize //foo/
   /foo
   % file normalize ///foo
   /foo
   % file normalize /foo//bar
   /foo/bar
   % file normalize //foo/bar
   //foo/bar
   % file normalize //foo//bar
   /foo/bar
   % file normalize //foo/bar/
   /foo/bar

   % set tcl_patchLevel
   8.6.6
Referenced by10
  • 7c88980794Closed ticket [1752589fff]: file normalize misses two leading / on first level catalog plus 4 other changes ticket2026-10-21 10:03:39
  • 1f8fa30714Open ticket [baf4387372]: file join trashes valid network paths plus 5 other changes ticket2018-07-27 17:15:44
  • 0895787e36Ticket [baf4387372] file join trashes valid network paths status still Open with 4 other changes ticket2018-07-27 11:03:10
  • 36ecfc49e7Ticket [f9fe90d0fa] Inconsistent handling of leading // status still Open with 3 other changes ticket2017-04-29 11:05:52
  • e895b53905[f34cf83dd0] An optimization was being taken in a case where it produced the wrong result, failing to collapse multiple /// into /. Testing on Windows where path expectations may vary would be a good idea, but since this is just an optimization avoidance, I suspect we're ok. check-in2017-04-28 17:57:34
  • e015bfe72f[f34cf83dd0] An optimization was being taken in a case where it produced the wrong result, failing to collapse multiple /// into /. Testing on Windows where path expectations may vary would be a good idea, but since this is just an optimization avoidance, I suspect we're ok. check-in2017-04-28 17:52:26
  • 2158eea530[f34cf83dd0] An optimization was being taken in a case where it produced the wrong result, failing to collapse multiple /// into /. Testing on Windows where path expectations may vary would be a good idea, but since this is just an optimization avoidance, I suspect we're ok. check-in2017-04-28 17:49:43
  • 769ae9c349Test for [f34cf83dd0]. check-in2017-04-28 17:46:11
  • 9a6ff36832Test for [f34cf83dd0]. check-in2017-04-28 17:44:31
  • f49a421a0dTest for [f34cf83dd0]. check-in2017-04-28 17:43:49
dgpplain2017-04-27 14:29:53
Bisecting points the blame at

https://core.tcl.tk/tcl/info/9cfcca63fb0
dgpplain2017-04-28 16:41:03
It appears this traces down to a flaw in [file join]
machinery:

% info patch
8.4.20
% file join foo /bar
/bar
%  file join foo //bar
/bar
%  file join foo ///bar
/bar

% info patch
8.6.6
% file join foo /bar
/bar
% file join foo //bar
//bar
% file join foo ///bar
/bar
dgpplain2017-04-28 17:59:43
Fixed on all dev branches
gustafn2plain2017-05-06 12:52:37
Great, Many thanks!
Log in (anonymous is fine) to add a comment.