.
D 2015-07-07T17:20:42.497
J assignee nobody
J closer nobody
J cmimetype text/html
J comment The\scommand\s[glob\s-dir\s$path\s*]\sfails\swhen\s$path\sis\svery\sdeeply\snested;\sthis\smakes\sit\simpossible\s(AFAICT)\sto\straverse\sa\sdeeply\snested\sdirectory\shierarchy.\sIt\sdoesn't\smatter\swhether\s$path\sis\sa\splain\spath,\sor\sbegins\swith\sthe\s//?/\slong\spath\sprefix.\sSome\s(but\snot\sall)\sof\sthe\s[file]\scommands\scan\shandle\slong\spaths,\sdepending\son\sthe\sTcl\sversion.\s\r\n\r\nHere\sis\sa\sprogram\sthat\sillustrates\ssome\sof\sthe\sdeficiencies\sand\sdifferences:\r\n\r\n<pre>\r\n#\sWindows\s[glob]\sbug\sdemo.\sFor\sbackground\sinfo\ssee:\r\n#\shttps://groups.google.com/forum/#!topic/comp.lang.tcl/5awD6g40jrg\s\r\n#\shttps://core.tcl.tk/tcl/tktview/1479814fffffffffffff\r\n#\shttps://core.tcl.tk/tcl/tktview/3389978fffffffffffff\r\n\r\ncatch\s{console\sshow}\r\nputs\s"Tcl\s[info\spatchlevel]"\r\nupdate\r\n\r\n#\sMake\sa\spath\s>300\scharacters\sby\sadding\s5\sat\sa\stime.\r\nset\slvl\s0\r\nset\spath\s[pwd]\r\nwhile\s{[string\slength\s$path]\s<=\s300}\s{\r\n\tincr\slvl\r\n\tappend\spath\s/path\r\n}\r\nputs\s"Path\slength:\s[string\slength\s$path]"\r\n\r\n#\sTest\swhether\s[file\smkdir]\scan\screate\sa\sdirectory\sunder\sit.\r\nputs\s-nonewline\s"File\smkdir\swith\splain\spath"\r\nif\s{[catch\s{file\smkdir\s$path/path}\serr]}\s{\r\n\tputs\s":\sfailed"\r\n\tputs\s-nonewline\s"File\smkdir\swith\slong\spath\sprefix"\r\n\tif\s{[catch\s{file\smkdir\s//?/$path/path}\serr]}\s{\r\n\t\tputs\s-nonewline\s":\sfailed"\r\n\t\tvwait\sforever\r\n\t}\r\n}\r\nputs\s""\r\n\r\n#\sTest\swhether\s[file\sexists]\scan\ssee\sit.\r\nif\s{[catch\s{file\sexists\s$path}\sexists]}\s{set\sexists\s"failed"}\r\nputs\s"File\sexists\swith\splain\spath:\s$exists"\r\nif\s{[catch\s{file\sexists\s//?/$path}\sexists]}\s{set\sexists\s"failed"}\r\nputs\s"File\sexists\swith\slong\spath\sprefix:\s$exists"\r\n\r\n#\sTest\swhether\s[glob]\scan\ssee\sit.\r\nif\s{[catch\s{llength\s[glob\s$path]}\smatches]}\s{set\smatches\s"failed"}\r\nputs\s"Glob\swith\splain\spath:\s$matches"\r\nif\s{[catch\s{llength\s[glob\s//?/$path]}\smatches]}\s{set\smatches\s"failed"}\r\nputs\s"Glob\swith\slong\spath\sprefix:\s$matches"\r\n\r\n#\sTest\swhether\s[glob\s-dir]\scan\ssee\sthe\ssubdirectory.\r\nif\s{[catch\s{llength\s[glob\s-dir\s$path\s*]}\smatches]}\s{set\smatches\s"failed"}\r\nputs\s"Glob\s-dir\swith\splain\spath:\s$matches"\r\nif\s{[catch\s{llength\s[glob\s-dir\s//?/$path\s*]}\smatches]}\s{set\smatches\s"failed"}\r\nputs\s"Glob\s-dir\swith\slong\spath\sprefix:\s$matches"\r\n\r\n#\sTest\swhether\s[glob]\scan\ssee\sthe\ssubdirectory.\r\nif\s{[catch\s{llength\s[glob\s$path/path]}\smatches]}\s{set\smatches\s"failed"}\r\nputs\s"Glob\son\ssubdir\swith\splain\spath:\s$matches"\r\nif\s{[catch\s{llength\s[glob\s//?/$path/path]}\smatches]}\s{set\smatches\s"failed"}\r\nputs\s"Glob\son\ssubdir\swith\slong\spath\sprefix:\s$matches"\r\n\r\n#\sTest\swhether\s[file\sdelete]\scan\sdelete\sit.\r\nputs\s-nonewline\s"File\sdelete\swith\splain\spath"\r\nif\s{[catch\s{file\sdelete\s-force\s[pwd]/path}\serr]}\s{\r\n\tputs\s":\sfailed"\r\n\tputs\s-nonewline\s"File\sdelete\swith\slong\spath\sprefix"\r\n\tif\s{[catch\s{file\sdelete\s-force\s//?/[pwd]/path}\serr]}\s{\r\n\t\tputs\s-nonewline\s":\sfailed"\r\n\t\t#\sDelete\sit\siteratively.\r\n\t\twhile\s{$lvl\s>\s0}\s{\r\n\t\t\tincr\slvl\s-1\r\n\t\t\tfile\srename\s-force\spath/path\stmp\r\n\t\t\tfile\sdelete\s-force\spath\s\r\n\t\t\tfile\srename\s-force\stmp\spath\r\n\t\t}\r\n\t\tfile\sdelete\s-force\spath\r\n\t}\r\n}\r\nputs\s""\r\n</pre>\r\n\r\nHere\sare\sthe\sresults\sfor\sTcl\s8.6.4\sand\s8.5.17\s(note\sthat\sactually\stested\sthis\susing\sTclkits,\snot\sfull\sTcl\sinstalls):\r\n\r\n<pre>\r\nTcl\s8.6.4\r\nPath\slength:\s301\r\nFile\smkdir\swith\splain\spath:\sfailed\r\nFile\smkdir\swith\slong\spath\sprefix\r\nFile\sexists\swith\splain\spath:\s1\r\nFile\sexists\swith\slong\spath\sprefix:\s1\r\nGlob\swith\splain\spath:\s1\r\nGlob\swith\slong\spath\sprefix:\s1\r\nGlob\s-dir\swith\splain\spath:\sfailed\r\nGlob\s-dir\swith\slong\spath\sprefix:\sfailed\r\nGlob\son\ssubdir\swith\splain\spath:\s1\r\nGlob\son\ssubdir\swith\slong\spath\sprefix:\s1\r\nFile\sdelete\swith\splain\spath:\sfailed\r\nFile\sdelete\swith\slong\spath\sprefix:\sfailed\r\n</pre>\r\n\r\n<pre>\r\nTcl\s8.5.17\r\nPath\slength:\s301\r\nFile\smkdir\swith\splain\spath:\sfailed\r\nFile\smkdir\swith\slong\spath\sprefix\r\nFile\sexists\swith\splain\spath:\s0\r\nFile\sexists\swith\slong\spath\sprefix:\s1\r\nGlob\swith\splain\spath:\sfailed\r\nGlob\swith\slong\spath\sprefix:\s1\r\nGlob\s-dir\swith\splain\spath:\sfailed\r\nGlob\s-dir\swith\slong\spath\sprefix:\sfailed\r\nGlob\son\ssubdir\swith\splain\spath:\sfailed\r\nGlob\son\ssubdir\swith\slong\spath\sprefix:\s1\r\nFile\sdelete\swith\splain\spath:\sfailed\r\nFile\sdelete\swith\slong\spath\sprefix:\sfailed\r\n</pre>\r\n\r\nAs\syou\scan\ssee,\s[glob\s//?/$path]\sworks\son\sboth,\sbut\s[glob\s$path]\sworks\sonly\son\sthe\smore\srecent\sversion\sof\sTcl.\sBut\sneither\s[glob\s-dir\s//?/$path\s*]\snor\s[glob\s-dir\s$path\s*]\sworks\sat\sall,\sand\sthat's\swhat\syou\sneed\sin\sorder\sto\straverse\sa\sdirectory\shierarchy.
J foundin 8.5.17
J is_private 0
J login john.j.seal
J priority 5\sMedium
J private_contact e1e289e81f931be9eb396cfee59849a6b74fd383
J resolution None
J severity Important
J status Open
J submitter john.j.seal
J subsystem 36.\sPathname\sManagement
J title [glob\s-dir\s$path\s*]\sdoesn't\swork\sfor\sdeeply\snested\spaths
J type Bug
K 3eace1b21f66da738cd1769e4ec69cb0f50e6029
U john.j.seal
Z a54d8e50167f6c9d7ff69d662f7a55ac