Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/glob?V=74
QUERY_STRINGV=74
CONTENT_TYPE
DOCUMENT_URI/revision/glob
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.69.58.83
REMOTE_PORT32324
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR18.225.31.159
HTTP_CF_RAY87b08b440eb61193-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP18.225.31.159
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit glob '''\[http://www.tcl.tk/man/tcl/TclCmd/glob.htm%|%glob\]'''\ is\ a\ \[Tcl\nCommands%|%built-in\]\ Tcl\ \[command\]\n\n**\ See\ Also\ **\n\n\ \ \ \ :\ \ \ '''glob'''\ ?''switches...''?\ ''pattern''\ ?''pattern\ ...''?\n\nSupported\ ''switches''\ are:\n\n\ \ \ \ :\ \ \ '''-directory'''\ ''directory''\n\ \ \ \ :\ \ \ '''-join'''\n\ \ \ \ :\ \ \ '''-nocomplain'''\n\ \ \ \ :\ \ \ '''-path'''\ ''pathPrefix''\n\ \ \ \ :\ \ \ '''-tails'''\n\ \ \ \ :\ \ \ '''-types'''\ ''typeList''\n\ \ \ \ :\ \ \ '''--'''\n\n\n\n**\ Documentation\ **\n\n\ \ \ \ \[http://www.tcl.tk/man/tcl/TclCmd/glob.htm%|%official\ reference\]:\ \ \ \n\ \ \ \ :\ \ \ http://www.tcl.tk/man/tcl/TclCmd/glob.htm%\ \ \ \n\n\n**\ Description\ **\n\n'''`glob`'''\ lists\ all\ the\ directory\ entries\ whose\ names\ match\ a\ given\n'''`glob`'''\ lists\ all\ the\ directory\ entries\ (files,\ directories,\ and\ links)\nwhose\ names\ match\ a\ given\ pattern.\ \nThe\ following\ two\ cases\ are\ errors:\n\n***\ `glob`\ raises\ an\ exception\;\ the\ `-nocomplain`\ option\ ***\nIf\ no\ files\ or\ directories\ were\ found,\ the\ command\nIf\ no\ files\ or\ directories\ were\ found,\ the\ command\ \nbehavior\ of\ \[Unix\]'s\ '''ls''':\n\n======none\n\$\ ls\ not_existing\nls:\ not_existing:\ No\ such\ file\ or\ directory\n\$\ echo\ \$?\n1\n======\n\n\[PYK\]\ 2016-11-16:\ \ Except\ that\ it\ doesn't\ model\ the\ behaviour\ of\ ls\ in\ other\n\n***\ Use\ `--`\ to\ separate\ switches\ from\ arguments\ ***\n**\ Use\ `--`\ to\ separate\ switches\ from\ arguments\ **\ncontain\ arbitrary\ characters\ or\ might\ get\ a\ preceding\ dash\ through\ substitution.\n\n\n\n***\ The\ `-types`\ option\ ***\n**\ The\ `-types`\ option\ **\n\n======\nglob\ -types\ hidden\ *\nglob\ -types\ d\ *\n======\n\nThere\ are\ cross-OS\ issues\ with\ this\ (in\ particular\ the\ handling\ of\ hidden\ files),\ \nsee\ below.\n\nTo\ get\ a\ list\ of\ all\ contents\ of\ a\ directory\ that\ aren't\ themselves\ndirectories,\ including\ broken\ symbolic\ links\ (`\[lsort\]\ -unique`\ is\ used\ \nin\ case\ an\ item\ gets\ listed\ by\ both\ invocations\ of\ `glob`):\n\n======\nset\ itemlist\ \[\nset\ itemlist\ \[concat\ \\\n\ \ \ \ \[glob\ -nocomplain\ -directory\ \$dir\ -types\ hidden\ *\]\ \\\n\ \ \ \ \[glob\ -nocomplain\ -directory\ \$dir\ *\]\]\nset\ onlyfiles\ \[lmap\ item\ \[lsort\ -unique\ \$itemlist\]\ \{\n\ \ \ \ expr\ \{!\[file\ isdirectory\ \$item\]\ &&\ \[file\ tail\ \$item\]\ ni\ \{.\ ..\}\n\ \ \ \ expr\ \{!\[file\ isdirectory\ \$item\]\ &&\ \$item\ ni\ \{.\ ..\}\n\ \ \ \ \ \ \ \ :\ \[continue\]\n\ \ \ \ \}\n\}\]\n======\n\n\[\[name\ redacted\]\]:\ I\ rewrote\ the\ script\ some.\n\[PL\]:\ I\ rewrote\ the\ script\ some.\nI\ left\ the\ subcondition\ `\[\[\[file\ tail\]\ \$item\]\]\ ni\ \{.\ ..\}`\ in,\ even\ \nI\ left\ the\ subcondition\ `\$item\ ni\ \{.\ ..\}`\ in,\ even\ \n`!\[\[\[file\ isdirectory\]\ \$item\]\]`\ alone,\ i.e.\ this\ invocation\ ought\ to\ do:\n`!\[\[file\ isdirectory\ \$item\]\]`\ alone,\ i.e.\ this\ invocation\ ought\ to\ do:\n======\nexpr\ \{!\[file\ isdirectory\ \$item\]\ ?\ \$item\ :\ \[continue\]\ \}\n======\n\n\[PYK\]\ 2014-08-13:\ edited\ the\ example\ above\ to\ use\ `\[\[\[file\ tail\]\ \$item\]\]`\n\n***\ The\ `-directory`\ and\ `-path`\ options\ ***\n(Note\ that\ these\ are\ mutually\ exclusive.\ Also\ note\ that\ `-directory`\ can\ be\nabbreviated\ to\ `-dir`.)\n\nLet's\ say\ I\ want\ to\ find\ all\ files\ in\ a\ directory,\ then\ I\ use\ (ignoring\ hidden\nfiles\ for\ the\ moment)\n\n======\nglob\ -dir\ \$dir\ *\n======\n\nNow,\ what\ I\ want\ all\ files\ in\ that\ directory\ whose\ names\ start\ with\ `\$nametail`\n(where\ I\ have\ no\ idea\ what\ characters\ are\ in\ `\$nametail`).\ \ I\ could\ try:\n\n======\nglob\ -dir\ \$dir\ \$\{nametail\}*\n======\n\nbut\ that\ would\ fail\ (either\ with\ an\ error\ or\ not\ the\ expected\ result)\ if\nnametail\ contains\ characters\ like\ `\{\}`.\ \ Therefore\ I\ must\ use\ ''-path'',\ like\nthis:\n\n======\nglob\ -path\ \$dir/\$nametail\ *\n#\ or\ even\ (see\ below)\nglob\ -join\ -path\ \$dir\ \$nametail\ *\n======\n\nOne\ thing\ to\ be\ aware\ of\ is\ that\ `-dir\ \{\}`\ is\ the\ same\ as\ `-dir\ .`.\ \ Hopefully\nthis\ wart\ will\ be\ removed\ in\ the\ future.\n\n\n**\ The\ `-join`\ option\ **\n***\ The\ `-join`\ option\ ***\nWhen\ to\ use\ ''-join''?\n\nIf\ I\ want\ to\ find\ all\ `*.tcl`\ files\ in\ any\ subdirectory\ of\ a\ known\ directory,\ I\ncould\ try\ this:\n\n======\nglob\ -dir\ \$dir\ */*.tcl\n======\n\nbut\ that\ won't\ work\ on\ MacOS.\ \ So,\ use\ `-join`:\n\n======\nglob\ -join\ -dir\ \$dir\ *\ *.tcl\n======\n\n\n**\ Trailing\ `/`\ **\n***\ Odds\ and\ ends\ ***\nIn\ a\ recent\ email\ thread\ on\ the\ \[Modules\]\ mailing\ list,\ a\ developer\ reported\ a\n\n****\ Trailing\ `/`\ ****\n\nchange\ he\ found\ when\ beginning\ to\ use\ Tcl\ 8.5:\n\n===\n\$\ tclsh8.4\n%\ glob\ /home/\n/home\n%\ glob\ /home\n/home\n^D\n\$\ tclsh8.5\n%\ glob\ /home/\n/home/\n%\ glob\ /home\n/home\n^D\n\n===\n\nTurns\ out\ that\ the\ modules\ package\ was\ dependent\ on\ having\ the\ path\ returned\nwithout\ the\ trailing\ `/`,\ and\ when\ 8.5\ started\ returning\ some\ paths\ with\ the\nslash,\ certain\ behaviors\ changed.\n\nFrom\ a\ purely\ technical\ point\ of\ view,\ the\ two\ forms\ of\ the\ name\ are\ considered\nequivalent\ by\ the\ operating\ systems\ with\ which\ I\ am\ familar\ (Ultrix,\ Solaris,\netc.).\ I\ don't\ know\ if\ there\ are\ differences\ for\ variants\ or\ not.\ \n\n\[\[name\ redacted\]\]:\ In\ Tcl\ 8.6,\ this\ seems\ to\ be\ changed\ ''again'':\ no\ trailing\ slashes\ are\ \n\[PL\]:\ In\ Tcl\ 8.6,\ this\ seems\ to\ be\ changed\ ''again'':\ no\ trailing\ slashes\ are\ \n\nIn\ any\ case,\ `file\ normalize`\ removes\ any\ trailing\ slashes\ present:\n\n===\nstring\ equal\ \[file\ nor\ \[glob\ /Tcl/\]\]\ \[file\ nor\ \[glob\ /Tcl\]\]\n#\ =>\ (should\ be\ 1\ on\ all\ versions)\nstring\ equal\ \[file\ nor\ /foo/\]\ \[file\ nor\ /foo\]\n#\ =>\ 1\n===\n\n\[APN\]\ I\ don't\ see\ 8.6\ having\ changed\ again.\ At\ least\ not\ on\ Windows.\ If\n===\n****\ `glob`\ does\ not\ sort\ ****\n\nmight\ have\ to\ use\ `\[lsort\]`\ on\ the\ file\ list\ (note\ the\ various\ settings\ of\ the\ \n`lsort`\ command:\ especially\ differences\ between\ `-ascii`\ and\ `-dictionary`\ \nsorting,\ the\ option\ to\ choose\ increasing\ or\ decreasing\ order,\ the\ option\ to\ \nignore\ case\ difference,\ and\ the\ option\ to\ provide\ an\ adhoc\ comparison\ command):\n\n======\nset\ files\ \[lsort\ \[glob\ *\]\]\ \;#\ will\ probably\ suffice\ in\ most\ cases\nset\ files\ \[lsort\ -dictionary\ -decreasing\ -nocase\ \[glob\ *\]\]\n======\n\n\n\n****\ Negated\ patterns\ ****\n**\ Negated\ patterns\ **\n\[LV\]:\ does\ anyone\ have\ some\ tcl\ code\ for\ handling\ negated\ patterns?\ \ The\ \[ksh\]\nglob\ function\ allows\ me\ to\ do\ things\ like\ !(o*)\ or\ ab\[\[!b-z\]\ and\ I\ would\ like\n\n\[\[name\ redacted\]\]:\ This\ one\ is\ still\ open,\ though\ one\ might\ possibly\ `glob`\ two\ lists,\ one\ \n\[PL\]:\ This\ one\ is\ still\ open,\ though\ one\ might\ possibly\ `glob`\ two\ lists,\ one\ \nfrom\ the\ first.\ There\ may\ be\ issues\ with\ this\ that\ need\ to\ be\ investigated,\ \nthough.\n\n\n\n\[\[name\ redacted\]\]:\ The\ following\ command\ is\ intended\ to\ ''start''\ a\ discussion,\ not\ to\ be\ \n\[PL\]:\ The\ following\ command\ is\ intended\ to\ ''start''\ a\ discussion,\ not\ to\ be\ \n\n======\n#\ untested\ code\nproc\ negatedGlob\ pattern\ \{\n\ \ \ \ set\ allfiles\ \[glob\ -nocomplain\ *\]\n\ \ \ \ set\ matchedfiles\ \[glob\ -nocomplain\ \$pattern\]\n\ \ \ \ ldiff\ \$allfiles\ \$matchedfiles\n\}\n======\n\n<<discussion>>\n\n\n****\ Use\ of\ braces\ ****\n\nOne\ might\ consider\ at\ least\ one\ of\ glob's\ behaviors\ as\ a\ \[Tcl\ warts%|%wart\].\nglob\ uses\ the\ brace\ (`\{\}`)\ characters\ as\ special\ notation,\ even\ though\ the\ tcl\nparser\ ALSO\ uses\ these\ characters.\ \ The\ result\ is\ that\ one\ needs\ to\ learn,\ from\narguments.\ \ glob\ also\ uses\ the\ \[\[\ and\ \]\]\ characters\ and\ those\ need\ quoted\ as\nwell.\n\nVince:\ fortunately\ with\ the\ use\ of\ '-dir'\ or\ '-path'\ flags\ to\ glob\ the\ need\ for\nquoting\ is\ pretty\ much\ gone\ in\ Tcl\ 8.3\ or\ newer.\n\n\n****\ Recursive\ `glob`\ ****\n\n<<discussion>>Recursive\ `glob`\n**\ Filename\ Encodings\ **\nsure\ what\ happens\ with\ links)\ and\ returns\ all\ non-directories\ in\ alphabetic\norder:\n\n======\nproc\ glob-r\ \{\{dir\ .\}\}\ \{\n\ \ \ \ set\ res\ \{\}\n\ \ \ \ foreach\ i\ \[lsort\ \[glob\ -nocomplain\ -dir\ \$dir\ *\]\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\[file\ type\ \$i\]\ eq\ \{directory\}\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\[file\ type\ \$i\]==\"directory\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ eval\ lappend\ \ res\ \[glob-r\ \$i\]\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ res\ \$i\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ set\ res\n\}\ \;#\ RS\n======\n\n(Verified\ works\ with\ 8.6.)\n(\[PL\]:\ verified\ works\ with\ 8.6.)\n\[JH\]\ 2006-05-16:\ With\ this\ variant\ that\ allows\ for\ optional\ patterns\ of\ninterest,\ like\ `glob-r\ C:/Tcl\ *.gif\ *.ps`:\ninterest,\ like\ '''glob-r\ C:/Tcl\ *.gif\ *.ps''':\n======\nproc\ glob-r\ \{\{dir\ .\}\ args\}\ \{\n\ \ \ \ set\ res\ \{\}\n\ \ \ \ foreach\ i\ \[lsort\ \[glob\ -nocomplain\ -dir\ \$dir\ *\]\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\[file\ isdirectory\ \$i\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ eval\ \[list\ lappend\ res\]\ \[eval\ \[linsert\ \$args\ 0\ glob-r\ \$i\]\]\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[llength\ \$args\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ foreach\ arg\ \$args\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[string\ match\ \$arg\ \$i\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lappend\ res\ \$i\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ break\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lappend\ res\ \$i\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$res\n\}\ \;#\ JH\n======\n\n(Invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n(\[PL\]:\ invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n\[MG\]\ 2004-05-20:\ I\ couldn't\ get\ the\ above\ code\ to\ work,\ so\ wrote\ my\ own\ version\nof\ it.\ The\ only\ oddity\ about\ it\ is\ that\ paths\ (sometimes)\ start\ `././`,\ rather\nof\ it.\ The\ only\ oddity\ about\ it\ is\ that\ paths\ (sometimes)\ start\ '././',\ rather\nthan\ just\ './'\ -\ I\ really\ don't\ know\ why.\ But\ using\ \[\[file\ exists\]\]\ on\ those\nfiles\ still\ works,\ so\ it\ doesn't\ really\ seem\ to\ matter.\ (It\ also\ uses\ \[\[info\nlevel\ 0\]\]\ to\ find\ out\ it's\ own\ name\ when\ it\ calls\ itself\ recursively\;\ this\ is,\nsimply,\ because\ I\ just\ found\ out\ how\ you\ do\ that\ :)\ Replacing\ ''\[\[lindex\ \[\[info\nlevel\ 0\]\]\ 0\]\]''\ with\ ''globRec''\ (or\ whatever\ you\ call\ the\ procedure)\ will\nspeed\ it\ up\ a\ fair\ bit.\ ''Changed\ quickly\ to\ add\ --\ into\ the\ \[\[glob\]\]\ calls,\ so\n\$dir\ can't\ be\ mistaken\ as\ a\ switch,\ as\ suggested\ above''.\ Takes\ an\ optional\nsecond\ argument\ to\ specify\ which\ types\ of\ file\ to\ \[\[glob\]\]\ for\;\ by\ default,\ all\n\n======\nproc\ globRec\ \{\{dir\ .\}\ \{types\ \{b\ c\ f\ l\ p\ s\}\}\}\ \{\n\ \ \ \ set\ files\ \[glob\ -nocomplain\ -types\ \$types\ -dir\ \$dir\ --\ *\]\n\ \ \ \ foreach\ x\ \[glob\ -nocomplain\ -types\ \{d\}\ -dir\ \$dir\ --\ *\]\ \{\n\ \ \ \ \ \ \ \ set\ files\ \[\n\ \ \ \ \ \ \ \ \ \ \ \ concat\ \$files\ \[\[lindex\ \[info\ level\ 0\]\ 0\]\ \[file\ join\ \$dir\ \$x\]\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ concat\ \$files\ \[\[lindex\ \[info\ level\ 0\]\ 0\]\ \[file\ join\ \$dir\ \$x\]\]\]\n\ \ \ \ \ \ \ \ \}\n\}\ \;#\ globRec\n======\n\n(Invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n(\[PL\]:\ invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\nTC\ 2004-11-23:\ I\ couldn't\ get\ either\ of\ the\ above\ functions\ to\ do\ what\ I\nwanted,\ which\ was\ to\ recursively\ list\ all\ directories\ and\ use\ a\ filespec.\ \ My\nTcl\ hack\ (lightly\ tested\ on\ 8.3\ and\ 8.5)\ of\ \[MG\]'s\ code,\ which\ seems\ to\ do\ all\nTCL\ hack\ (lightly\ tested\ on\ 8.3\ and\ 8.5)\ of\ \[MG\]'s\ code,\ which\ seems\ to\ do\ all\nto\ support\ filenames\ with\ spaces\ in\ them.\n\nNote:\ you\ may\ need\ to\ replace\ `\[file\ join\]\ \$dir\ \$x`\ with\ simply\ `\$x`.\ I\ had\ to.\n\n======\nproc\ globRec\ \{\{dir\ .\}\ \{filespec\ *\}\ \{types\ \{b\ c\ f\ l\ p\ s\}\}\}\ \{\nproc\ globRec\ \{\{dir\ .\}\ \{filespec\ \"*\"\}\ \{types\ \{b\ c\ f\ l\ p\ s\}\}\}\ \{\n\ \ \ \ foreach\ x\ \[glob\ -nocomplain\ -types\ \{d\}\ -dir\ \$dir\ --\ *\]\ \{\n\ \ \ \ \ \ \ \ set\ files\ \[concat\ \$files\ \[globRec\ \[file\ join\ \$dir\ \$x\]\ \$filespec\ \$types\]\]\n\ \ \ \ \}\n\ \ \ \ set\ filelist\ \{\}\n\ \ \ \ foreach\ x\ \$files\ \{\n\ \ \ \ \ \ \ \ while\ \{\[string\ range\ \$x\ 0\ 1\]\ eq\ \{./\}\}\ \{\n\ \ \ \ \ \ \ \ while\ \{\[string\ range\ \$x\ 0\ 1\]==\"./\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ regsub\ ./\ \$x\ \"\"\ x\n\ \ \ \ \ \ \ \ lappend\ filelist\ \$x\n\ \ \ \ \}\n\ \ \ \ return\ \$filelist\;\n\}\;#\ globRec\n======\n\n(Invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n(\[PL\]:\ invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n----\n\n\[jys\]:\ I\ wanted\ a\ recursive\ glob\ that\ would\ take\ the\ same\ options\ as\ glob,\ so\ I\nwrote\ this\ wrapper.\ I\ don't\ know\ if\ it\ works\ 100%\ with\ all\ options\ though,\ and\nit\ currently\ gets\ tripped\ up\ by\ glob\ spitting\ the\ dummy\ when\ it\ can't\ look\ninside\ a\ directory\ (generally\ 'cause\ of\ permissions).\n\n======\nproc\ rglob\ \{args\}\ \{\n\ \ \ \ #\ This\ code\ requires\ -join\ and\ -nocomplain.\ We\ also\ remove\ the\ -types\ option,\ and\ then\ manually\ apply\ a\ filter\ at\ the\ end.\n\ \ \ \ set\ args\ \[linsert\ \$args\ 0\ -nocomplain\ -join\]\n\ \ \ \ if\ \{\[set\ types_index\ \[lsearch\ -exact\ \$args\ -types\]\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ set\ types\ \[lindex\ \$args\ \[expr\ \{\$types_index+1\}\]\]\n\ \ \ \ \ \ \ \ set\ args\ \[lreplace\ \$args\ \$types_index\ \[expr\ \{\$types_index+1\}\]\]\n\ \ \ \ \}\n\ \ \ \ \n\ \ \ \ #\ Get\ inital\ matches.\n\ \ \ \ set\ matches\ \[glob\ \{*\}\$args\]\n\ \ \ \ \n\ \ \ \ #\ Keep\ adding\ *\ wildcards\ to\ search\ through\ subdirectories\ until\ there\ are\ no\ more\ levels\ of\ directories\ to\ search.\n\ \ \ \ while\ \{\[llength\ \[glob\ -types\ d\ \{*\}\[lreplace\ \$args\ end\ end\ *\]\]\]\ >\ 0\}\ \{\n\ \ \ \ \ \ \ \ set\ args\ \[linsert\ \$args\ end-1\ *\]\n\ \ \ \ \ \ \ \ lappend\ matches\ \{*\}\[glob\ \{*\}\$args\]\n\ \ \ \ \}\n\ \ \ \ \n\ \ \ \ #\ Filter\ matches\ with\ -types\ option.\n\ \ \ \ if\ \{\[info\ exists\ types\]\}\ \{\n\ \ \ \ \ \ \ \ set\ matches\ \[glob\ -nocomplain\ -types\ \$types\ \{*\}\$matches\]\}\n\ \ \ \ return\ \$matches\n\}\n======\n\n(Hangs\ Tcl\ 8.6\ (made\ no\ attempt\ to\ find\ cause\ of\ problem).)\n(\[PL\]:\ hangs\ Tcl\ 8.6\ (made\ no\ attempt\ to\ find\ cause\ of\ problem).)\n\n<<discussion>>findfile\n\ncustomized\ to\ quickly\ find\ the\ first\ instance\ of\ a\ file\ in\ a\ given\ path.\n\n======\nproc\ findfile\ \{\ dir\ fname\ \}\ \{\n\ \ \ \ if\ \{\n\ \ \ \ \ \ \ \ \[llength\ \[set\ x\ \[glob\ -nocomplain\ -dir\ \$dir\ \$fname\]\]\]\n\ \ \ \ \}\ \{\n\ \ \ \ \ \ \ \ return\ \[lindex\ \$x\ 0\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ foreach\ i\ \[glob\ -nocomplain\ -type\ d\ -dir\ \$dir\ *\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$i\ !=\ \$dir\ &&\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[llength\ \[set\ x\ \[findfile\ \$i\ \$fname\]\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\ \$x\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n======\n\n(Verified\ works\ with\ 8.6.)\n(\[PL\]:\ verified\ works\ with\ 8.6.)\n\n<<discussion>>listTree\n\nthe\ full\ path\ name\ of\ all\ descendants.\ It\ embeds\ glob\ in\ a\ recursive\ call\;\ a\ndirectory\ with\ no\ descendants\ is\ the\ base\ case.\n\n======\nproc\ listTree\ \{rootdir_\}\ \{\n#\ Precondition:\ rootdir_\ is\ valid\ path\ \n\ \ \ \ set\ currentnodes\ \[glob\ -nocomplain\ -directory\ \$rootdir_\ -types\ d\ *\]\n\ \ \ \ if\ \{\[llength\ \$currentnodes\]\ <=\ 0\}\ \{\n\ \ \ \ #\ Base\ case:\ the\ current\ dir\ is\ a\ leaf,\ write\ out\ the\ leaf\ \n\ \ \ \ \ \ \ \ puts\ \$rootdir_\n\ \ \ \ \ \ \ \ return\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ write\ out\ the\ current\ node\ \n\ \ \ \ \ \ \ \ puts\ \$rootdir_\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ Recurse\ over\ all\ dirs\ at\ this\ level\n\ \ \ \ \ \ \ \ foreach\ node\ \$currentnodes\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ listTree\ \$node\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n\nlistTree\ \[pwd\]\n======\n\n(Verified\ works\ with\ 8.6\ (and\ is\ surprisingly\ quick).)\n(\[PL\]:\ verified\ works\ with\ 8.6\ (and\ is\ surprisingly\ quick).)\n(Original\ command\ author):\ That\ this\ isn't\ a\ Tcl\ built-in\ (or\ if\ it\ is,\ why\ is\ it\ is\ such\ a\ well-kept\nsecret)\ strikes\ me\ as\ odd.\ \n\nI\ remember\ reading\ something\ about\ a\ pre-defined\ limit\ on\ depth\ of\ recursion\ in\nTcl,\ so\ this\ code\ is\ not\ guaranteed\ for\ arbitrarily\ deep\ file\ structures.\n\nBob\n\n\n<<discussion>>\n\n**\ `pathentry`\ **\n****\ `pathentry`\ ****\n\[MSW\]:\ \[pathentry\]:\ Entry\ widget/binding\ set\ using\ `glob`\ to\ offer\ quick\nauto-completion\ of\ paths\n\n\n\n****\ The\ DKF\ star\ ****\n**\ The\ DKF\ star\ **\n\n======\nproc\ *\ args\ \{glob\ -nocomplain\ *\[join\ \$args\ \{\}\]\}\n======\n\n\[CMCc\]:\ Now\ try\ the\ same\ kind\ of\ composition\ and\ extension\ under\ /bin/sh\ :)\n\n\[MJ\]:\ \ Shouldn't\ this\ be:\n\ \n======\nproc\ *\ args\ \{glob\ -nocomplain\ *\\\{\[join\ \$args\ ,\]\\\}\}\n======\n\nBecause\ \[DKF\]'s\ version\ doesn't\ do\ what\ I\ expect\ it\ to\ do\ with\ multiple\ args\n(maybe\ my\ expectation\ is\ wrong)\ \n\n\n\n****\ Unglobbing\ ****\n**\ Unglobbing\ **\nin\ \[https://groups.google.com/d/msg/comp.lang.tcl/ogIayrQo4Zg/O1-8pa2tnrcJ%|%array\ unset\ gotcha\],\ \[comp.lang.tcl\],\ 2007-09-13:\nin\ \[http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/a2021acab428e198/b79eadada5bc5f3b#b79eadada5bc5f3b\]:\n======\nset\ bar\ \{x\[y\]\}\nset\ foo(\$bar)\ yes\narray\ unset\ foo\ \$bar\nparray\ foo\ =>\ foo(x\[y\])\ still\ exists\n======\n\nWhat's\ the\ cure,\ Doctor?\ '''Unglob\ it!'''\n\n======\nproc\ unglob\ \{x\}\ \{\n\ \ \ \ string\ map\ \{*\ \\\\*\ ?\ \\\\?\ \[\ \\\\\[\ \]\ \\\\\]\}\ \$x\n\}\n======\n\n\n\n***\ Cross-OS\ issues\ ***\n**\ Hidden\ files\ **\nEven\ though\ the\ proper\ directory\ separator\ character\ on\ \[Microsoft\n****\ Hidden\ files\ ****\n\nEven\ though\ the\ proper\ directory\ separator\ character\ on\ Windows\ is\ a\ backslash\ (`\\`),\ a\ regular\ \nslash\ works\ fine\ both\ in\ Tcl\ code\ and\ in\ the\ command\ line\ of\ a\ Tcl\ or\ Tk\ shell.\ \ This\ means\ that\ \none\ can\ usually\ be\ mostly\ compatible\ with\ both\ Windows\ and\ Unix\ by\ using\ slashes\ (though\ methods\ \nlike\ `file\ join`\ etc\ are\ still\ recommended\ for\ truly\ compatible\ path\ names\ and\ file\ patterns).\nOn\ unix\ and\ OS\ X,\ `glob\ -types\ hidden\ *`\ returns\ all\ files\ beginning\ with\ a\ period\ (.),\ including\n`.`\ and\ `..`.\ \ On\ Windows\ and\ Classic\ Mac\ OS,\ this\ returns\ files\ that\ have\ntheir\ hidden\ attribute\ set\ (and\ (at\ least\ on\ Windows)\ ''does\ not''\ list\ files\ with\ names\ beginning\nwith\ a\ period,\ except\ if\ they\ have\ the\ hidden\ attribute\ set).\n\nOn\ Windows,\ `glob\ *`\ returns\ files\ beginning\ with\ `.`,\ while\ On\ *nix\ systems,\nit\ does\ not.\n\nSee\ the\ discussion\ of\ the\ `-types`\ option\ above\ for\ a\ cross-OS\ way\ to\ list\ all\ entries\ in\ a\ given\ndirectory.\n\n----\n\nThe\ following\ attempt\ works\ on\ *nix,\ but\ can\ return\ duplicates\ on\ Windows:\n\n======\nlsort\ \[glob\ -dir\ \$dir\ \{.*,*\}\]\]\n======\n\n\n\n****\ Windows\ drive\ globbing\ ****\n**\ Windows\ drive\ globbing\ **\n\n======\nglob\ -dir\ c:\ *\n======\n\nwill\ list\ contents\ of\ ''the\ current\ working\ directory\ on\ drive\ C:,''\ not\ the\ncontents\ of\ the\ root\ folder\ on\ that\ drive.\n\nTo\ get\ the\ latter,\ add\ trailing\ slash\ to\ the\ drive\ letter:\n\n======\nglob\ -dir\ c:/\ *\n======\n\nThe\ described\ behaviour\ is\ consistent\ with\ what\ is\ seen\ in\ '''cmd.exe'''\ncommand\ shell.\n\nThanks\ \[PT\]\ for\ explaining\ this\ issue.\n\n\[Zipguy\]\ 2013-02-07\ -\ Thanks\ \[kostix\]\ for\ pointing\ this\ out.\ \ I\ do\ use\ windows\n(and\ strongly\ love/hate\ it).\ \ I\ found\ this\ very\ interesting\ so\ I\ tried\ it.\ I\nwas\ running\ a\ program\ called\ \[ML\ -\ Heavily\ Modified\ &\ Improved\]\ using\ntclkit-8.5.8.exe,\ in\ which\ mine\ was\ the\ current\ directory,\ so\ I\ opened\ a\nconsole\ window\ and\ typed\ in:\n\n======none\n(mine)\ 3\ %\ glob\ -dir\ d:\ *\n======\n\nand\ what\ I\ got\ was:\n\n<<discussion>>(results)\n\n======none\nd:action-demo.tcl\ d:action.tcl\ d:awf.kit\ d:awfgreat.kit\ d:awf_cfg.ml\nd:bindb.bat\ d:bindb.kit\ d:bindb.tcl\ d:bindb.vfs\ d:bindcbk.tcl\ d:clipr.kit\nd:clipr.vfs\ d:colorp.dat\ d:colorp.kit\ d:dler.kit\ d:dler.vfs\ d:eff-font.txt\nd:efftcl.kit\ d:efftcl.vfs\ d:ezsdx.bat\ d:ezsdx.kit\ d:ezsdxc.dat\ d:ezsdxgreat.kit\nd:ezsdxh.dat\ d:help.dat\ d:icons\ d:links.txt\ d:ml.bat\ d:ml.kit\ d:ml.txt\nd:mlalpha.kit\ d:mlgreat.bat\ d:mlgreat.kit\ d:mlgreatold.kit\ d:ml_cfg.ml\n\{d:ml_cfg.ml.\$\$\$\}\ d:output.html\ d:output.tcl\ d:output2.html\ d:panedwindow.tcl\nd:progress.tcl\ d:progressbar.txt\ d:res.tcl\ d:sbf.tcl\ d:scrollb.tcl\ d:sdx.kit\nd:sdx.vfs\ d:sdxnew.kit\ d:sdxold.kit\ d:t.kit\ d:t.tcl\ d:t.vfs\ d:tclkit-8.5.8.exe\nd:tclkit-8.5.9.exe\ d:tgood.kit\ d:timeplay\ d:timeplay.tcl\ d:timeplay.tcll\nd:Tk_coding_styles.txt\ d:widget\ d:wsf.kit\ d:wsf.vfs\ d:wsfold.kit\ d:wsfold.tcl\nd:wsfold.vfs\ d:wsforig.tcl\ d:XSCLOCK.TCL\ d:yacm.ini\ d:yacm.kit\ d:yacm.txt\nd:yacm2.kit\ d:yacmgood.kit\ d:yacmo.kit\ d:ypedit.tcl\ d:zipper.tcl\n======\n\nwhich\ did\ surprise\ me.\n\nIt\ did\ come\ back\ with\ all\ of\ these\ files\ (which\ was\ expected),\ which\ were\ on\nthe\ proper\ drive,\ namely\ d:,\ in\ the\ proper\ directory,\ namely\ mine\ (or\ more\nprecisely\ \"D:\\dl\\dcl\\mine\\\"),\ but,\ it\ did\ prefix\ all\ of\ them\ with\ the\ \"d:\"\n(which\ was\ unexpected).\ \ For\ example,\ \"d:tclkit-8.5.9.exe\"\ which\ is\ there\ and\n\"\{d:ml_cfg.ml.\$\$\$\}\"\ which\ it\ did\ enclose\ in\ curly\ brackets,\ which\ I\ do\nunderstand\ (in\ case\ they\ have\ spaces\ or\ special\ characters\ in\ them).\n\nAnyway,\ I\ decided\ to\ try\ a\ more\ complex\ version,\ which\ would\ list\ the\ directory\nabove\ the\ current\ one\ (which\ is\ kind\ of\ dangerous\ if\ it\ doesn't\ exist,\ unknown)\nlike\ this:\n\n======none\n(mine)\ 5\ %\ glob\ -dir\ d:../\ *\n======\n\nand\ (lo\ and\ behold,)\ it\ did\ produce\ this:\n\n======none\nd:../caps\ d:../desktop\ d:../ezsdx\ d:../ezsdx.kit\ d:../ezsdxc.dat\ d:../ezsdxgreat.kit\ \nd:../ezsdxh.dat\ d:../fd\ d:../freepdf\ d:../freepdflogoweeebxd.jpg\ d:../freewrap6.2\ \nd:../irfanview_screenshot_1.jpg\ d:../irfanview_screenshot_2.jpg\ d:../irfanview_step1.jpg\ \nd:../irfanview_step2.jpg\ d:../irfanview_step3.jpg\ d:../jasspa-mechm-ms-win32-20091011.zip\ \nd:../mine\ d:../ml\ d:../ml.kit\ d:../ml124d_procw_colors.jpg\ d:../ml124d_screen.jpg\ \nd:../ml124d_screen_rightclick_meni.jpg\ d:../ml124d_status_line.jpg\ d:../ml124d_toolbar.jpg\ \nd:../mlgreat.kit\ d:../mlgreatold.kit\ d:../sdx.kit\ d:../sdxe.dat\ d:../sdxnew.kit\ d:../sdxold.kit\ \ \nd:../setup-jasspame-20091011.exe\ d:../stock\ d:../t.kit\ d:../tclkit-8.5.8-win32-x86_64.exe\ \nd:../tclkit852.exe\ d:../tgood.kit\ d:../tgoodold.kit\ d:../viewIcons.kit\n======\n\nwhich\ did\ work\ but\ provided\ a\ prefix\ of\ \"d:../\"\ rather\ than\ the\ previous\ncommand\ which\ provided\ a\ prefix\ of\ \ \"d:\"\ which\ does\ make\ sense\ also.\n\n======none\n(mine)\ 7\ %\ glob\ -dir\ d:../../\ *\n======\n\nand\ this\n\n======none\nd:../../@tcl\ d:../../bas\ d:../../browser\ d:../../dcl\ d:../../dler\nd:../../editor\ d:../../flv\ d:../../fonts\ d:../../games\ d:../../good\nd:../../html\ d:../../img\ d:../../mid\ d:../../misc\ d:../../nc\ d:../../new\nd:../../new2\ d:../../new3\ d:../../new4\ d:../../new5\ d:../../zip\n======\n\nBut\ more\ importantly,\ should\ I\ write\ a\ proc\ to\ strip\ out\ the\ \"d:\"'s\ (or\n\"d:../\"'s)\ in\ front\ of\ them,\ or\ use\ a\ better\ undocumented\ glob\ option?\n\nYes,\ I\ did\ read\ (and\ re-read)\ all\ about\ glob\ for\ \"ActiveState\ ActiveTcl\n8.4.19.5.294332\"\ (which\ was\ produced\ in\ Feb\ 11,\ 2011)\ which\ may\ mean\ it\ has\nbeen\ documented\ in\ a\ later\ version.\n\n<<discussion>>\n\n\[MG\]\ Add\ the\ `-tails`\ option\ to\ \[glob\].\n\n\n\n***\ Version\ issues\ ***\n**\ Stale\ links\ **\n(Also\ see\ \"Trailing\ `/`\"\ above.)\n\[RS\]:\ \n\n****\ Stale\ links\ ****\n\n\n'''Stale\ links:'''\ ''glob''\ in\ older\ (pre\ Tcl\ 8.4a4)\ versions\ of\ Tcl\ has\ a\nfunny\ behavior\ (seen\ on\ Solaris\ 5.5.1)\ with\ symbolic\ links\ that\ don't\ point\ to\nan\ existing\ file:\n\n======none\n%\ exec\ ln\ -s\ /does/not/exist\ stalelink\n%\ glob\ stalelink\nno\ files\ matched\ glob\ pattern\ \"stalelink\"\n%\ glob\ stalelink*\nstalelink\n======\n\nIf\ the\ pattern\ is\ not\ wildcarded,\ it\ tries\ to\ follow\ the\ link\;\ otherwise\ it\njust\ returns\ the\ link's\ name\ itself.\ Hmm...\n\n\n\n****\ Tilde\ paths\ ****\n**\ Tilde\ paths\ **\nspecially\ by\ \[glob\]'',\ but\ shouldn't\ that\ have\ been\ done\ to\ avoid\ a\ security\nproblem\ with\ ~\ expansion\ ?\ e.g:\n\n======\nforeach\ file\ \[glob\ *\]\ \{\n\ \ \ \ file\ delete\ -force\ \$file\n\}\n======\n\nwhere\ \[glob\]\ returns\ a\ file\ beginning\ with\ a\ ~\ ?\n\n\[Vince\]\ writes:\ for\ historical\ reasons\ the\ code\ above\ is\ considered\nwrong/buggy.\ \ You\ should\ write\ `file\ delete\ -force\ ./\$file`.\ \ This\ is\ perhaps\nsomething\ that\ should\ be\ changed\ in\ the\ future,\ but\ it\ might\ well\ break\ some\nold\ code.\ \ There\ is\ even\ a\ bug\ report\ or\ patch\ somewhere\ on\ sf\ about\ this,\ I\nthink\ (probably\ closed\ now).\n\n\n\n**\ See\ Also\ **\n\n\ \ \ \[Directory\ recursion\]:\ \ \ \n\n\n\ \ \ \[glob\ forwards\ compatibility\]:\ \ \ how\ to\ to\ override\ the\ older\ \[\[glob\]\]\ command.\n\n\n regexp2} CALL {my render glob '''\[http://www.tcl.tk/man/tcl/TclCmd/glob.htm%|%glob\]'''\ is\ a\ \[Tcl\nCommands%|%built-in\]\ Tcl\ \[command\]\n\n**\ See\ Also\ **\n\n\ \ \ \ :\ \ \ '''glob'''\ ?''switches...''?\ ''pattern''\ ?''pattern\ ...''?\n\nSupported\ ''switches''\ are:\n\n\ \ \ \ :\ \ \ '''-directory'''\ ''directory''\n\ \ \ \ :\ \ \ '''-join'''\n\ \ \ \ :\ \ \ '''-nocomplain'''\n\ \ \ \ :\ \ \ '''-path'''\ ''pathPrefix''\n\ \ \ \ :\ \ \ '''-tails'''\n\ \ \ \ :\ \ \ '''-types'''\ ''typeList''\n\ \ \ \ :\ \ \ '''--'''\n\n\n\n**\ Documentation\ **\n\n\ \ \ \ \[http://www.tcl.tk/man/tcl/TclCmd/glob.htm%|%official\ reference\]:\ \ \ \n\ \ \ \ :\ \ \ http://www.tcl.tk/man/tcl/TclCmd/glob.htm%\ \ \ \n\n\n**\ Description\ **\n\n'''`glob`'''\ lists\ all\ the\ directory\ entries\ whose\ names\ match\ a\ given\n'''`glob`'''\ lists\ all\ the\ directory\ entries\ (files,\ directories,\ and\ links)\nwhose\ names\ match\ a\ given\ pattern.\ \nThe\ following\ two\ cases\ are\ errors:\n\n***\ `glob`\ raises\ an\ exception\;\ the\ `-nocomplain`\ option\ ***\nIf\ no\ files\ or\ directories\ were\ found,\ the\ command\nIf\ no\ files\ or\ directories\ were\ found,\ the\ command\ \nbehavior\ of\ \[Unix\]'s\ '''ls''':\n\n======none\n\$\ ls\ not_existing\nls:\ not_existing:\ No\ such\ file\ or\ directory\n\$\ echo\ \$?\n1\n======\n\n\[PYK\]\ 2016-11-16:\ \ Except\ that\ it\ doesn't\ model\ the\ behaviour\ of\ ls\ in\ other\n\n***\ Use\ `--`\ to\ separate\ switches\ from\ arguments\ ***\n**\ Use\ `--`\ to\ separate\ switches\ from\ arguments\ **\ncontain\ arbitrary\ characters\ or\ might\ get\ a\ preceding\ dash\ through\ substitution.\n\n\n\n***\ The\ `-types`\ option\ ***\n**\ The\ `-types`\ option\ **\n\n======\nglob\ -types\ hidden\ *\nglob\ -types\ d\ *\n======\n\nThere\ are\ cross-OS\ issues\ with\ this\ (in\ particular\ the\ handling\ of\ hidden\ files),\ \nsee\ below.\n\nTo\ get\ a\ list\ of\ all\ contents\ of\ a\ directory\ that\ aren't\ themselves\ndirectories,\ including\ broken\ symbolic\ links\ (`\[lsort\]\ -unique`\ is\ used\ \nin\ case\ an\ item\ gets\ listed\ by\ both\ invocations\ of\ `glob`):\n\n======\nset\ itemlist\ \[\nset\ itemlist\ \[concat\ \\\n\ \ \ \ \[glob\ -nocomplain\ -directory\ \$dir\ -types\ hidden\ *\]\ \\\n\ \ \ \ \[glob\ -nocomplain\ -directory\ \$dir\ *\]\]\nset\ onlyfiles\ \[lmap\ item\ \[lsort\ -unique\ \$itemlist\]\ \{\n\ \ \ \ expr\ \{!\[file\ isdirectory\ \$item\]\ &&\ \[file\ tail\ \$item\]\ ni\ \{.\ ..\}\n\ \ \ \ expr\ \{!\[file\ isdirectory\ \$item\]\ &&\ \$item\ ni\ \{.\ ..\}\n\ \ \ \ \ \ \ \ :\ \[continue\]\n\ \ \ \ \}\n\}\]\n======\n\n\[\[name\ redacted\]\]:\ I\ rewrote\ the\ script\ some.\n\[PL\]:\ I\ rewrote\ the\ script\ some.\nI\ left\ the\ subcondition\ `\[\[\[file\ tail\]\ \$item\]\]\ ni\ \{.\ ..\}`\ in,\ even\ \nI\ left\ the\ subcondition\ `\$item\ ni\ \{.\ ..\}`\ in,\ even\ \n`!\[\[\[file\ isdirectory\]\ \$item\]\]`\ alone,\ i.e.\ this\ invocation\ ought\ to\ do:\n`!\[\[file\ isdirectory\ \$item\]\]`\ alone,\ i.e.\ this\ invocation\ ought\ to\ do:\n======\nexpr\ \{!\[file\ isdirectory\ \$item\]\ ?\ \$item\ :\ \[continue\]\ \}\n======\n\n\[PYK\]\ 2014-08-13:\ edited\ the\ example\ above\ to\ use\ `\[\[\[file\ tail\]\ \$item\]\]`\n\n***\ The\ `-directory`\ and\ `-path`\ options\ ***\n(Note\ that\ these\ are\ mutually\ exclusive.\ Also\ note\ that\ `-directory`\ can\ be\nabbreviated\ to\ `-dir`.)\n\nLet's\ say\ I\ want\ to\ find\ all\ files\ in\ a\ directory,\ then\ I\ use\ (ignoring\ hidden\nfiles\ for\ the\ moment)\n\n======\nglob\ -dir\ \$dir\ *\n======\n\nNow,\ what\ I\ want\ all\ files\ in\ that\ directory\ whose\ names\ start\ with\ `\$nametail`\n(where\ I\ have\ no\ idea\ what\ characters\ are\ in\ `\$nametail`).\ \ I\ could\ try:\n\n======\nglob\ -dir\ \$dir\ \$\{nametail\}*\n======\n\nbut\ that\ would\ fail\ (either\ with\ an\ error\ or\ not\ the\ expected\ result)\ if\nnametail\ contains\ characters\ like\ `\{\}`.\ \ Therefore\ I\ must\ use\ ''-path'',\ like\nthis:\n\n======\nglob\ -path\ \$dir/\$nametail\ *\n#\ or\ even\ (see\ below)\nglob\ -join\ -path\ \$dir\ \$nametail\ *\n======\n\nOne\ thing\ to\ be\ aware\ of\ is\ that\ `-dir\ \{\}`\ is\ the\ same\ as\ `-dir\ .`.\ \ Hopefully\nthis\ wart\ will\ be\ removed\ in\ the\ future.\n\n\n**\ The\ `-join`\ option\ **\n***\ The\ `-join`\ option\ ***\nWhen\ to\ use\ ''-join''?\n\nIf\ I\ want\ to\ find\ all\ `*.tcl`\ files\ in\ any\ subdirectory\ of\ a\ known\ directory,\ I\ncould\ try\ this:\n\n======\nglob\ -dir\ \$dir\ */*.tcl\n======\n\nbut\ that\ won't\ work\ on\ MacOS.\ \ So,\ use\ `-join`:\n\n======\nglob\ -join\ -dir\ \$dir\ *\ *.tcl\n======\n\n\n**\ Trailing\ `/`\ **\n***\ Odds\ and\ ends\ ***\nIn\ a\ recent\ email\ thread\ on\ the\ \[Modules\]\ mailing\ list,\ a\ developer\ reported\ a\n\n****\ Trailing\ `/`\ ****\n\nchange\ he\ found\ when\ beginning\ to\ use\ Tcl\ 8.5:\n\n===\n\$\ tclsh8.4\n%\ glob\ /home/\n/home\n%\ glob\ /home\n/home\n^D\n\$\ tclsh8.5\n%\ glob\ /home/\n/home/\n%\ glob\ /home\n/home\n^D\n\n===\n\nTurns\ out\ that\ the\ modules\ package\ was\ dependent\ on\ having\ the\ path\ returned\nwithout\ the\ trailing\ `/`,\ and\ when\ 8.5\ started\ returning\ some\ paths\ with\ the\nslash,\ certain\ behaviors\ changed.\n\nFrom\ a\ purely\ technical\ point\ of\ view,\ the\ two\ forms\ of\ the\ name\ are\ considered\nequivalent\ by\ the\ operating\ systems\ with\ which\ I\ am\ familar\ (Ultrix,\ Solaris,\netc.).\ I\ don't\ know\ if\ there\ are\ differences\ for\ variants\ or\ not.\ \n\n\[\[name\ redacted\]\]:\ In\ Tcl\ 8.6,\ this\ seems\ to\ be\ changed\ ''again'':\ no\ trailing\ slashes\ are\ \n\[PL\]:\ In\ Tcl\ 8.6,\ this\ seems\ to\ be\ changed\ ''again'':\ no\ trailing\ slashes\ are\ \n\nIn\ any\ case,\ `file\ normalize`\ removes\ any\ trailing\ slashes\ present:\n\n===\nstring\ equal\ \[file\ nor\ \[glob\ /Tcl/\]\]\ \[file\ nor\ \[glob\ /Tcl\]\]\n#\ =>\ (should\ be\ 1\ on\ all\ versions)\nstring\ equal\ \[file\ nor\ /foo/\]\ \[file\ nor\ /foo\]\n#\ =>\ 1\n===\n\n\[APN\]\ I\ don't\ see\ 8.6\ having\ changed\ again.\ At\ least\ not\ on\ Windows.\ If\n===\n****\ `glob`\ does\ not\ sort\ ****\n\nmight\ have\ to\ use\ `\[lsort\]`\ on\ the\ file\ list\ (note\ the\ various\ settings\ of\ the\ \n`lsort`\ command:\ especially\ differences\ between\ `-ascii`\ and\ `-dictionary`\ \nsorting,\ the\ option\ to\ choose\ increasing\ or\ decreasing\ order,\ the\ option\ to\ \nignore\ case\ difference,\ and\ the\ option\ to\ provide\ an\ adhoc\ comparison\ command):\n\n======\nset\ files\ \[lsort\ \[glob\ *\]\]\ \;#\ will\ probably\ suffice\ in\ most\ cases\nset\ files\ \[lsort\ -dictionary\ -decreasing\ -nocase\ \[glob\ *\]\]\n======\n\n\n\n****\ Negated\ patterns\ ****\n**\ Negated\ patterns\ **\n\[LV\]:\ does\ anyone\ have\ some\ tcl\ code\ for\ handling\ negated\ patterns?\ \ The\ \[ksh\]\nglob\ function\ allows\ me\ to\ do\ things\ like\ !(o*)\ or\ ab\[\[!b-z\]\ and\ I\ would\ like\n\n\[\[name\ redacted\]\]:\ This\ one\ is\ still\ open,\ though\ one\ might\ possibly\ `glob`\ two\ lists,\ one\ \n\[PL\]:\ This\ one\ is\ still\ open,\ though\ one\ might\ possibly\ `glob`\ two\ lists,\ one\ \nfrom\ the\ first.\ There\ may\ be\ issues\ with\ this\ that\ need\ to\ be\ investigated,\ \nthough.\n\n\n\n\[\[name\ redacted\]\]:\ The\ following\ command\ is\ intended\ to\ ''start''\ a\ discussion,\ not\ to\ be\ \n\[PL\]:\ The\ following\ command\ is\ intended\ to\ ''start''\ a\ discussion,\ not\ to\ be\ \n\n======\n#\ untested\ code\nproc\ negatedGlob\ pattern\ \{\n\ \ \ \ set\ allfiles\ \[glob\ -nocomplain\ *\]\n\ \ \ \ set\ matchedfiles\ \[glob\ -nocomplain\ \$pattern\]\n\ \ \ \ ldiff\ \$allfiles\ \$matchedfiles\n\}\n======\n\n<<discussion>>\n\n\n****\ Use\ of\ braces\ ****\n\nOne\ might\ consider\ at\ least\ one\ of\ glob's\ behaviors\ as\ a\ \[Tcl\ warts%|%wart\].\nglob\ uses\ the\ brace\ (`\{\}`)\ characters\ as\ special\ notation,\ even\ though\ the\ tcl\nparser\ ALSO\ uses\ these\ characters.\ \ The\ result\ is\ that\ one\ needs\ to\ learn,\ from\narguments.\ \ glob\ also\ uses\ the\ \[\[\ and\ \]\]\ characters\ and\ those\ need\ quoted\ as\nwell.\n\nVince:\ fortunately\ with\ the\ use\ of\ '-dir'\ or\ '-path'\ flags\ to\ glob\ the\ need\ for\nquoting\ is\ pretty\ much\ gone\ in\ Tcl\ 8.3\ or\ newer.\n\n\n****\ Recursive\ `glob`\ ****\n\n<<discussion>>Recursive\ `glob`\n**\ Filename\ Encodings\ **\nsure\ what\ happens\ with\ links)\ and\ returns\ all\ non-directories\ in\ alphabetic\norder:\n\n======\nproc\ glob-r\ \{\{dir\ .\}\}\ \{\n\ \ \ \ set\ res\ \{\}\n\ \ \ \ foreach\ i\ \[lsort\ \[glob\ -nocomplain\ -dir\ \$dir\ *\]\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\[file\ type\ \$i\]\ eq\ \{directory\}\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\[file\ type\ \$i\]==\"directory\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ eval\ lappend\ \ res\ \[glob-r\ \$i\]\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ res\ \$i\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ set\ res\n\}\ \;#\ RS\n======\n\n(Verified\ works\ with\ 8.6.)\n(\[PL\]:\ verified\ works\ with\ 8.6.)\n\[JH\]\ 2006-05-16:\ With\ this\ variant\ that\ allows\ for\ optional\ patterns\ of\ninterest,\ like\ `glob-r\ C:/Tcl\ *.gif\ *.ps`:\ninterest,\ like\ '''glob-r\ C:/Tcl\ *.gif\ *.ps''':\n======\nproc\ glob-r\ \{\{dir\ .\}\ args\}\ \{\n\ \ \ \ set\ res\ \{\}\n\ \ \ \ foreach\ i\ \[lsort\ \[glob\ -nocomplain\ -dir\ \$dir\ *\]\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\[file\ isdirectory\ \$i\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ eval\ \[list\ lappend\ res\]\ \[eval\ \[linsert\ \$args\ 0\ glob-r\ \$i\]\]\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[llength\ \$args\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ foreach\ arg\ \$args\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[string\ match\ \$arg\ \$i\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lappend\ res\ \$i\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ break\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lappend\ res\ \$i\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$res\n\}\ \;#\ JH\n======\n\n(Invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n(\[PL\]:\ invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n\[MG\]\ 2004-05-20:\ I\ couldn't\ get\ the\ above\ code\ to\ work,\ so\ wrote\ my\ own\ version\nof\ it.\ The\ only\ oddity\ about\ it\ is\ that\ paths\ (sometimes)\ start\ `././`,\ rather\nof\ it.\ The\ only\ oddity\ about\ it\ is\ that\ paths\ (sometimes)\ start\ '././',\ rather\nthan\ just\ './'\ -\ I\ really\ don't\ know\ why.\ But\ using\ \[\[file\ exists\]\]\ on\ those\nfiles\ still\ works,\ so\ it\ doesn't\ really\ seem\ to\ matter.\ (It\ also\ uses\ \[\[info\nlevel\ 0\]\]\ to\ find\ out\ it's\ own\ name\ when\ it\ calls\ itself\ recursively\;\ this\ is,\nsimply,\ because\ I\ just\ found\ out\ how\ you\ do\ that\ :)\ Replacing\ ''\[\[lindex\ \[\[info\nlevel\ 0\]\]\ 0\]\]''\ with\ ''globRec''\ (or\ whatever\ you\ call\ the\ procedure)\ will\nspeed\ it\ up\ a\ fair\ bit.\ ''Changed\ quickly\ to\ add\ --\ into\ the\ \[\[glob\]\]\ calls,\ so\n\$dir\ can't\ be\ mistaken\ as\ a\ switch,\ as\ suggested\ above''.\ Takes\ an\ optional\nsecond\ argument\ to\ specify\ which\ types\ of\ file\ to\ \[\[glob\]\]\ for\;\ by\ default,\ all\n\n======\nproc\ globRec\ \{\{dir\ .\}\ \{types\ \{b\ c\ f\ l\ p\ s\}\}\}\ \{\n\ \ \ \ set\ files\ \[glob\ -nocomplain\ -types\ \$types\ -dir\ \$dir\ --\ *\]\n\ \ \ \ foreach\ x\ \[glob\ -nocomplain\ -types\ \{d\}\ -dir\ \$dir\ --\ *\]\ \{\n\ \ \ \ \ \ \ \ set\ files\ \[\n\ \ \ \ \ \ \ \ \ \ \ \ concat\ \$files\ \[\[lindex\ \[info\ level\ 0\]\ 0\]\ \[file\ join\ \$dir\ \$x\]\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ concat\ \$files\ \[\[lindex\ \[info\ level\ 0\]\ 0\]\ \[file\ join\ \$dir\ \$x\]\]\]\n\ \ \ \ \ \ \ \ \}\n\}\ \;#\ globRec\n======\n\n(Invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n(\[PL\]:\ invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\nTC\ 2004-11-23:\ I\ couldn't\ get\ either\ of\ the\ above\ functions\ to\ do\ what\ I\nwanted,\ which\ was\ to\ recursively\ list\ all\ directories\ and\ use\ a\ filespec.\ \ My\nTcl\ hack\ (lightly\ tested\ on\ 8.3\ and\ 8.5)\ of\ \[MG\]'s\ code,\ which\ seems\ to\ do\ all\nTCL\ hack\ (lightly\ tested\ on\ 8.3\ and\ 8.5)\ of\ \[MG\]'s\ code,\ which\ seems\ to\ do\ all\nto\ support\ filenames\ with\ spaces\ in\ them.\n\nNote:\ you\ may\ need\ to\ replace\ `\[file\ join\]\ \$dir\ \$x`\ with\ simply\ `\$x`.\ I\ had\ to.\n\n======\nproc\ globRec\ \{\{dir\ .\}\ \{filespec\ *\}\ \{types\ \{b\ c\ f\ l\ p\ s\}\}\}\ \{\nproc\ globRec\ \{\{dir\ .\}\ \{filespec\ \"*\"\}\ \{types\ \{b\ c\ f\ l\ p\ s\}\}\}\ \{\n\ \ \ \ foreach\ x\ \[glob\ -nocomplain\ -types\ \{d\}\ -dir\ \$dir\ --\ *\]\ \{\n\ \ \ \ \ \ \ \ set\ files\ \[concat\ \$files\ \[globRec\ \[file\ join\ \$dir\ \$x\]\ \$filespec\ \$types\]\]\n\ \ \ \ \}\n\ \ \ \ set\ filelist\ \{\}\n\ \ \ \ foreach\ x\ \$files\ \{\n\ \ \ \ \ \ \ \ while\ \{\[string\ range\ \$x\ 0\ 1\]\ eq\ \{./\}\}\ \{\n\ \ \ \ \ \ \ \ while\ \{\[string\ range\ \$x\ 0\ 1\]==\"./\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ regsub\ ./\ \$x\ \"\"\ x\n\ \ \ \ \ \ \ \ lappend\ filelist\ \$x\n\ \ \ \ \}\n\ \ \ \ return\ \$filelist\;\n\}\;#\ globRec\n======\n\n(Invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n(\[PL\]:\ invocation\ without\ arguments\ verified\ works\ with\ 8.6.)\n----\n\n\[jys\]:\ I\ wanted\ a\ recursive\ glob\ that\ would\ take\ the\ same\ options\ as\ glob,\ so\ I\nwrote\ this\ wrapper.\ I\ don't\ know\ if\ it\ works\ 100%\ with\ all\ options\ though,\ and\nit\ currently\ gets\ tripped\ up\ by\ glob\ spitting\ the\ dummy\ when\ it\ can't\ look\ninside\ a\ directory\ (generally\ 'cause\ of\ permissions).\n\n======\nproc\ rglob\ \{args\}\ \{\n\ \ \ \ #\ This\ code\ requires\ -join\ and\ -nocomplain.\ We\ also\ remove\ the\ -types\ option,\ and\ then\ manually\ apply\ a\ filter\ at\ the\ end.\n\ \ \ \ set\ args\ \[linsert\ \$args\ 0\ -nocomplain\ -join\]\n\ \ \ \ if\ \{\[set\ types_index\ \[lsearch\ -exact\ \$args\ -types\]\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ set\ types\ \[lindex\ \$args\ \[expr\ \{\$types_index+1\}\]\]\n\ \ \ \ \ \ \ \ set\ args\ \[lreplace\ \$args\ \$types_index\ \[expr\ \{\$types_index+1\}\]\]\n\ \ \ \ \}\n\ \ \ \ \n\ \ \ \ #\ Get\ inital\ matches.\n\ \ \ \ set\ matches\ \[glob\ \{*\}\$args\]\n\ \ \ \ \n\ \ \ \ #\ Keep\ adding\ *\ wildcards\ to\ search\ through\ subdirectories\ until\ there\ are\ no\ more\ levels\ of\ directories\ to\ search.\n\ \ \ \ while\ \{\[llength\ \[glob\ -types\ d\ \{*\}\[lreplace\ \$args\ end\ end\ *\]\]\]\ >\ 0\}\ \{\n\ \ \ \ \ \ \ \ set\ args\ \[linsert\ \$args\ end-1\ *\]\n\ \ \ \ \ \ \ \ lappend\ matches\ \{*\}\[glob\ \{*\}\$args\]\n\ \ \ \ \}\n\ \ \ \ \n\ \ \ \ #\ Filter\ matches\ with\ -types\ option.\n\ \ \ \ if\ \{\[info\ exists\ types\]\}\ \{\n\ \ \ \ \ \ \ \ set\ matches\ \[glob\ -nocomplain\ -types\ \$types\ \{*\}\$matches\]\}\n\ \ \ \ return\ \$matches\n\}\n======\n\n(Hangs\ Tcl\ 8.6\ (made\ no\ attempt\ to\ find\ cause\ of\ problem).)\n(\[PL\]:\ hangs\ Tcl\ 8.6\ (made\ no\ attempt\ to\ find\ cause\ of\ problem).)\n\n<<discussion>>findfile\n\ncustomized\ to\ quickly\ find\ the\ first\ instance\ of\ a\ file\ in\ a\ given\ path.\n\n======\nproc\ findfile\ \{\ dir\ fname\ \}\ \{\n\ \ \ \ if\ \{\n\ \ \ \ \ \ \ \ \[llength\ \[set\ x\ \[glob\ -nocomplain\ -dir\ \$dir\ \$fname\]\]\]\n\ \ \ \ \}\ \{\n\ \ \ \ \ \ \ \ return\ \[lindex\ \$x\ 0\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ foreach\ i\ \[glob\ -nocomplain\ -type\ d\ -dir\ \$dir\ *\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$i\ !=\ \$dir\ &&\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[llength\ \[set\ x\ \[findfile\ \$i\ \$fname\]\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\ \$x\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n======\n\n(Verified\ works\ with\ 8.6.)\n(\[PL\]:\ verified\ works\ with\ 8.6.)\n\n<<discussion>>listTree\n\nthe\ full\ path\ name\ of\ all\ descendants.\ It\ embeds\ glob\ in\ a\ recursive\ call\;\ a\ndirectory\ with\ no\ descendants\ is\ the\ base\ case.\n\n======\nproc\ listTree\ \{rootdir_\}\ \{\n#\ Precondition:\ rootdir_\ is\ valid\ path\ \n\ \ \ \ set\ currentnodes\ \[glob\ -nocomplain\ -directory\ \$rootdir_\ -types\ d\ *\]\n\ \ \ \ if\ \{\[llength\ \$currentnodes\]\ <=\ 0\}\ \{\n\ \ \ \ #\ Base\ case:\ the\ current\ dir\ is\ a\ leaf,\ write\ out\ the\ leaf\ \n\ \ \ \ \ \ \ \ puts\ \$rootdir_\n\ \ \ \ \ \ \ \ return\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ write\ out\ the\ current\ node\ \n\ \ \ \ \ \ \ \ puts\ \$rootdir_\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ Recurse\ over\ all\ dirs\ at\ this\ level\n\ \ \ \ \ \ \ \ foreach\ node\ \$currentnodes\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ listTree\ \$node\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n\nlistTree\ \[pwd\]\n======\n\n(Verified\ works\ with\ 8.6\ (and\ is\ surprisingly\ quick).)\n(\[PL\]:\ verified\ works\ with\ 8.6\ (and\ is\ surprisingly\ quick).)\n(Original\ command\ author):\ That\ this\ isn't\ a\ Tcl\ built-in\ (or\ if\ it\ is,\ why\ is\ it\ is\ such\ a\ well-kept\nsecret)\ strikes\ me\ as\ odd.\ \n\nI\ remember\ reading\ something\ about\ a\ pre-defined\ limit\ on\ depth\ of\ recursion\ in\nTcl,\ so\ this\ code\ is\ not\ guaranteed\ for\ arbitrarily\ deep\ file\ structures.\n\nBob\n\n\n<<discussion>>\n\n**\ `pathentry`\ **\n****\ `pathentry`\ ****\n\[MSW\]:\ \[pathentry\]:\ Entry\ widget/binding\ set\ using\ `glob`\ to\ offer\ quick\nauto-completion\ of\ paths\n\n\n\n****\ The\ DKF\ star\ ****\n**\ The\ DKF\ star\ **\n\n======\nproc\ *\ args\ \{glob\ -nocomplain\ *\[join\ \$args\ \{\}\]\}\n======\n\n\[CMCc\]:\ Now\ try\ the\ same\ kind\ of\ composition\ and\ extension\ under\ /bin/sh\ :)\n\n\[MJ\]:\ \ Shouldn't\ this\ be:\n\ \n======\nproc\ *\ args\ \{glob\ -nocomplain\ *\\\{\[join\ \$args\ ,\]\\\}\}\n======\n\nBecause\ \[DKF\]'s\ version\ doesn't\ do\ what\ I\ expect\ it\ to\ do\ with\ multiple\ args\n(maybe\ my\ expectation\ is\ wrong)\ \n\n\n\n****\ Unglobbing\ ****\n**\ Unglobbing\ **\nin\ \[https://groups.google.com/d/msg/comp.lang.tcl/ogIayrQo4Zg/O1-8pa2tnrcJ%|%array\ unset\ gotcha\],\ \[comp.lang.tcl\],\ 2007-09-13:\nin\ \[http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/a2021acab428e198/b79eadada5bc5f3b#b79eadada5bc5f3b\]:\n======\nset\ bar\ \{x\[y\]\}\nset\ foo(\$bar)\ yes\narray\ unset\ foo\ \$bar\nparray\ foo\ =>\ foo(x\[y\])\ still\ exists\n======\n\nWhat's\ the\ cure,\ Doctor?\ '''Unglob\ it!'''\n\n======\nproc\ unglob\ \{x\}\ \{\n\ \ \ \ string\ map\ \{*\ \\\\*\ ?\ \\\\?\ \[\ \\\\\[\ \]\ \\\\\]\}\ \$x\n\}\n======\n\n\n\n***\ Cross-OS\ issues\ ***\n**\ Hidden\ files\ **\nEven\ though\ the\ proper\ directory\ separator\ character\ on\ \[Microsoft\n****\ Hidden\ files\ ****\n\nEven\ though\ the\ proper\ directory\ separator\ character\ on\ Windows\ is\ a\ backslash\ (`\\`),\ a\ regular\ \nslash\ works\ fine\ both\ in\ Tcl\ code\ and\ in\ the\ command\ line\ of\ a\ Tcl\ or\ Tk\ shell.\ \ This\ means\ that\ \none\ can\ usually\ be\ mostly\ compatible\ with\ both\ Windows\ and\ Unix\ by\ using\ slashes\ (though\ methods\ \nlike\ `file\ join`\ etc\ are\ still\ recommended\ for\ truly\ compatible\ path\ names\ and\ file\ patterns).\nOn\ unix\ and\ OS\ X,\ `glob\ -types\ hidden\ *`\ returns\ all\ files\ beginning\ with\ a\ period\ (.),\ including\n`.`\ and\ `..`.\ \ On\ Windows\ and\ Classic\ Mac\ OS,\ this\ returns\ files\ that\ have\ntheir\ hidden\ attribute\ set\ (and\ (at\ least\ on\ Windows)\ ''does\ not''\ list\ files\ with\ names\ beginning\nwith\ a\ period,\ except\ if\ they\ have\ the\ hidden\ attribute\ set).\n\nOn\ Windows,\ `glob\ *`\ returns\ files\ beginning\ with\ `.`,\ while\ On\ *nix\ systems,\nit\ does\ not.\n\nSee\ the\ discussion\ of\ the\ `-types`\ option\ above\ for\ a\ cross-OS\ way\ to\ list\ all\ entries\ in\ a\ given\ndirectory.\n\n----\n\nThe\ following\ attempt\ works\ on\ *nix,\ but\ can\ return\ duplicates\ on\ Windows:\n\n======\nlsort\ \[glob\ -dir\ \$dir\ \{.*,*\}\]\]\n======\n\n\n\n****\ Windows\ drive\ globbing\ ****\n**\ Windows\ drive\ globbing\ **\n\n======\nglob\ -dir\ c:\ *\n======\n\nwill\ list\ contents\ of\ ''the\ current\ working\ directory\ on\ drive\ C:,''\ not\ the\ncontents\ of\ the\ root\ folder\ on\ that\ drive.\n\nTo\ get\ the\ latter,\ add\ trailing\ slash\ to\ the\ drive\ letter:\n\n======\nglob\ -dir\ c:/\ *\n======\n\nThe\ described\ behaviour\ is\ consistent\ with\ what\ is\ seen\ in\ '''cmd.exe'''\ncommand\ shell.\n\nThanks\ \[PT\]\ for\ explaining\ this\ issue.\n\n\[Zipguy\]\ 2013-02-07\ -\ Thanks\ \[kostix\]\ for\ pointing\ this\ out.\ \ I\ do\ use\ windows\n(and\ strongly\ love/hate\ it).\ \ I\ found\ this\ very\ interesting\ so\ I\ tried\ it.\ I\nwas\ running\ a\ program\ called\ \[ML\ -\ Heavily\ Modified\ &\ Improved\]\ using\ntclkit-8.5.8.exe,\ in\ which\ mine\ was\ the\ current\ directory,\ so\ I\ opened\ a\nconsole\ window\ and\ typed\ in:\n\n======none\n(mine)\ 3\ %\ glob\ -dir\ d:\ *\n======\n\nand\ what\ I\ got\ was:\n\n<<discussion>>(results)\n\n======none\nd:action-demo.tcl\ d:action.tcl\ d:awf.kit\ d:awfgreat.kit\ d:awf_cfg.ml\nd:bindb.bat\ d:bindb.kit\ d:bindb.tcl\ d:bindb.vfs\ d:bindcbk.tcl\ d:clipr.kit\nd:clipr.vfs\ d:colorp.dat\ d:colorp.kit\ d:dler.kit\ d:dler.vfs\ d:eff-font.txt\nd:efftcl.kit\ d:efftcl.vfs\ d:ezsdx.bat\ d:ezsdx.kit\ d:ezsdxc.dat\ d:ezsdxgreat.kit\nd:ezsdxh.dat\ d:help.dat\ d:icons\ d:links.txt\ d:ml.bat\ d:ml.kit\ d:ml.txt\nd:mlalpha.kit\ d:mlgreat.bat\ d:mlgreat.kit\ d:mlgreatold.kit\ d:ml_cfg.ml\n\{d:ml_cfg.ml.\$\$\$\}\ d:output.html\ d:output.tcl\ d:output2.html\ d:panedwindow.tcl\nd:progress.tcl\ d:progressbar.txt\ d:res.tcl\ d:sbf.tcl\ d:scrollb.tcl\ d:sdx.kit\nd:sdx.vfs\ d:sdxnew.kit\ d:sdxold.kit\ d:t.kit\ d:t.tcl\ d:t.vfs\ d:tclkit-8.5.8.exe\nd:tclkit-8.5.9.exe\ d:tgood.kit\ d:timeplay\ d:timeplay.tcl\ d:timeplay.tcll\nd:Tk_coding_styles.txt\ d:widget\ d:wsf.kit\ d:wsf.vfs\ d:wsfold.kit\ d:wsfold.tcl\nd:wsfold.vfs\ d:wsforig.tcl\ d:XSCLOCK.TCL\ d:yacm.ini\ d:yacm.kit\ d:yacm.txt\nd:yacm2.kit\ d:yacmgood.kit\ d:yacmo.kit\ d:ypedit.tcl\ d:zipper.tcl\n======\n\nwhich\ did\ surprise\ me.\n\nIt\ did\ come\ back\ with\ all\ of\ these\ files\ (which\ was\ expected),\ which\ were\ on\nthe\ proper\ drive,\ namely\ d:,\ in\ the\ proper\ directory,\ namely\ mine\ (or\ more\nprecisely\ \"D:\\dl\\dcl\\mine\\\"),\ but,\ it\ did\ prefix\ all\ of\ them\ with\ the\ \"d:\"\n(which\ was\ unexpected).\ \ For\ example,\ \"d:tclkit-8.5.9.exe\"\ which\ is\ there\ and\n\"\{d:ml_cfg.ml.\$\$\$\}\"\ which\ it\ did\ enclose\ in\ curly\ brackets,\ which\ I\ do\nunderstand\ (in\ case\ they\ have\ spaces\ or\ special\ characters\ in\ them).\n\nAnyway,\ I\ decided\ to\ try\ a\ more\ complex\ version,\ which\ would\ list\ the\ directory\nabove\ the\ current\ one\ (which\ is\ kind\ of\ dangerous\ if\ it\ doesn't\ exist,\ unknown)\nlike\ this:\n\n======none\n(mine)\ 5\ %\ glob\ -dir\ d:../\ *\n======\n\nand\ (lo\ and\ behold,)\ it\ did\ produce\ this:\n\n======none\nd:../caps\ d:../desktop\ d:../ezsdx\ d:../ezsdx.kit\ d:../ezsdxc.dat\ d:../ezsdxgreat.kit\ \nd:../ezsdxh.dat\ d:../fd\ d:../freepdf\ d:../freepdflogoweeebxd.jpg\ d:../freewrap6.2\ \nd:../irfanview_screenshot_1.jpg\ d:../irfanview_screenshot_2.jpg\ d:../irfanview_step1.jpg\ \nd:../irfanview_step2.jpg\ d:../irfanview_step3.jpg\ d:../jasspa-mechm-ms-win32-20091011.zip\ \nd:../mine\ d:../ml\ d:../ml.kit\ d:../ml124d_procw_colors.jpg\ d:../ml124d_screen.jpg\ \nd:../ml124d_screen_rightclick_meni.jpg\ d:../ml124d_status_line.jpg\ d:../ml124d_toolbar.jpg\ \nd:../mlgreat.kit\ d:../mlgreatold.kit\ d:../sdx.kit\ d:../sdxe.dat\ d:../sdxnew.kit\ d:../sdxold.kit\ \ \nd:../setup-jasspame-20091011.exe\ d:../stock\ d:../t.kit\ d:../tclkit-8.5.8-win32-x86_64.exe\ \nd:../tclkit852.exe\ d:../tgood.kit\ d:../tgoodold.kit\ d:../viewIcons.kit\n======\n\nwhich\ did\ work\ but\ provided\ a\ prefix\ of\ \"d:../\"\ rather\ than\ the\ previous\ncommand\ which\ provided\ a\ prefix\ of\ \ \"d:\"\ which\ does\ make\ sense\ also.\n\n======none\n(mine)\ 7\ %\ glob\ -dir\ d:../../\ *\n======\n\nand\ this\n\n======none\nd:../../@tcl\ d:../../bas\ d:../../browser\ d:../../dcl\ d:../../dler\nd:../../editor\ d:../../flv\ d:../../fonts\ d:../../games\ d:../../good\nd:../../html\ d:../../img\ d:../../mid\ d:../../misc\ d:../../nc\ d:../../new\nd:../../new2\ d:../../new3\ d:../../new4\ d:../../new5\ d:../../zip\n======\n\nBut\ more\ importantly,\ should\ I\ write\ a\ proc\ to\ strip\ out\ the\ \"d:\"'s\ (or\n\"d:../\"'s)\ in\ front\ of\ them,\ or\ use\ a\ better\ undocumented\ glob\ option?\n\nYes,\ I\ did\ read\ (and\ re-read)\ all\ about\ glob\ for\ \"ActiveState\ ActiveTcl\n8.4.19.5.294332\"\ (which\ was\ produced\ in\ Feb\ 11,\ 2011)\ which\ may\ mean\ it\ has\nbeen\ documented\ in\ a\ later\ version.\n\n<<discussion>>\n\n\[MG\]\ Add\ the\ `-tails`\ option\ to\ \[glob\].\n\n\n\n***\ Version\ issues\ ***\n**\ Stale\ links\ **\n(Also\ see\ \"Trailing\ `/`\"\ above.)\n\[RS\]:\ \n\n****\ Stale\ links\ ****\n\n\n'''Stale\ links:'''\ ''glob''\ in\ older\ (pre\ Tcl\ 8.4a4)\ versions\ of\ Tcl\ has\ a\nfunny\ behavior\ (seen\ on\ Solaris\ 5.5.1)\ with\ symbolic\ links\ that\ don't\ point\ to\nan\ existing\ file:\n\n======none\n%\ exec\ ln\ -s\ /does/not/exist\ stalelink\n%\ glob\ stalelink\nno\ files\ matched\ glob\ pattern\ \"stalelink\"\n%\ glob\ stalelink*\nstalelink\n======\n\nIf\ the\ pattern\ is\ not\ wildcarded,\ it\ tries\ to\ follow\ the\ link\;\ otherwise\ it\njust\ returns\ the\ link's\ name\ itself.\ Hmm...\n\n\n\n****\ Tilde\ paths\ ****\n**\ Tilde\ paths\ **\nspecially\ by\ \[glob\]'',\ but\ shouldn't\ that\ have\ been\ done\ to\ avoid\ a\ security\nproblem\ with\ ~\ expansion\ ?\ e.g:\n\n======\nforeach\ file\ \[glob\ *\]\ \{\n\ \ \ \ file\ delete\ -force\ \$file\n\}\n======\n\nwhere\ \[glob\]\ returns\ a\ file\ beginning\ with\ a\ ~\ ?\n\n\[Vince\]\ writes:\ for\ historical\ reasons\ the\ code\ above\ is\ considered\nwrong/buggy.\ \ You\ should\ write\ `file\ delete\ -force\ ./\$file`.\ \ This\ is\ perhaps\nsomething\ that\ should\ be\ changed\ in\ the\ future,\ but\ it\ might\ well\ break\ some\nold\ code.\ \ There\ is\ even\ a\ bug\ report\ or\ patch\ somewhere\ on\ sf\ about\ this,\ I\nthink\ (probably\ closed\ now).\n\n\n\n**\ See\ Also\ **\n\n\ \ \ \[Directory\ recursion\]:\ \ \ \n\n\n\ \ \ \[glob\ forwards\ compatibility\]:\ \ \ how\ to\ to\ override\ the\ older\ \[\[glob\]\]\ command.\n\n\n} CALL {my revision glob} CALL {::oo::Obj2307311 process revision/glob} CALL {::oo::Obj2307309 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4