Error processing request
Parameters
CONTENT_LENGTH | 0 |
REQUEST_METHOD | GET |
REQUEST_URI | /revision/recursive_glob?V=5 |
QUERY_STRING | V=5 |
CONTENT_TYPE | |
DOCUMENT_URI | /revision/recursive_glob |
DOCUMENT_ROOT | /var/www/nikit/nikit/nginx/../docroot |
SCGI | 1 |
SERVER_PROTOCOL | HTTP/1.1 |
HTTPS | on |
REMOTE_ADDR | 172.69.7.12 |
REMOTE_PORT | 50076 |
SERVER_PORT | 4443 |
SERVER_NAME | wiki.tcl-lang.org |
HTTP_HOST | wiki.tcl-lang.org |
HTTP_CONNECTION | Keep-Alive |
HTTP_ACCEPT_ENCODING | gzip, br |
HTTP_X_FORWARDED_FOR | 3.15.165.2 |
HTTP_CF_RAY | 88dd53512ea16094-ORD |
HTTP_X_FORWARDED_PROTO | https |
HTTP_CF_VISITOR | {"scheme":"https"} |
HTTP_ACCEPT | */* |
HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected]) |
HTTP_REFERER | https://tcl.wiki/revision/recursive%5Fglob?V=5 |
HTTP_CF_CONNECTING_IP | 3.15.165.2 |
HTTP_CDN_LOOP | cloudflare |
HTTP_CF_IPCOUNTRY | US |
Body
Error
Unknow state transition: LINE -> END
-code
1
-level
0
-errorstack
INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit recursive_glob {This command is part of the [TclX] package.
: '''recursive_glob''' ''dirlist globlist''
Return a list of all files in/below directories in ''dirlist'' that match one of the patterns in ''globlist''. See also [for_recursive_glob].
----
[TR] Using Tcl 8.5 or newer, you can easily use the proc below instead, which is just an improved version of the TclX code:
======
proc rglob {dirlist globlist} {
set result {}
set recurse {}
foreach dir $dirlist {
if ![file isdirectory $dir] {
return -code error "'$dir' is not a directory"
}
foreach pattern $globlist {
lappend result {*}[glob -nocomplain -directory $dir -- $pattern]
}
foreach file [glob -nocomplain -directory $dir -- *] {
set file [file join $dir $file]
if [file isdirectory $file] {
set fileTail [file tail $file]
if {!($fileTail eq "." || $fileTail eq "..")} {
lappend recurse $file
}
}
}
}
if {[llength $recurse] > 0} {
lappend result {*}[rglob $recurse $globlist]
}
return $result
}
======
----
[tjk] The above code doesn't work (at least for me). Here is a version that works and include an exclusion list. This version doesn't take a list of directories as the first argument but I can't think of a good reason that it should.
======
proc rglob { dirpath patterns {exclude_pats {}} } {
set rlist {}
set exclude [glob -nocomplain -types f -directory ${dirpath} {*}${exclude_pats}]
foreach fpath [glob -nocomplain -types f -directory ${dirpath} {*}${patterns}] {
if { ${fpath} ni ${exclude} } {
lappend rlist ${fpath}
}
}
foreach dir [glob -nocomplain -types d -directory ${dirpath} *] {
lappend rlist {*}[rglob ${dir} ${patterns} ${exclude_pats}]
}
return ${rlist}
}
======
------
[RFox] Even more powerful is the fileutil::find command which uses a 'visitor pattern' to allow you to filter the files found in a directory tree via a script. since the script could have side effects, this also subsumes the [for_recursive_glob] functionality.
======
<<categories>>Command | TclX} regexp2} CALL {my render recursive_glob {This command is part of the [TclX] package.
: '''recursive_glob''' ''dirlist globlist''
Return a list of all files in/below directories in ''dirlist'' that match one of the patterns in ''globlist''. See also [for_recursive_glob].
----
[TR] Using Tcl 8.5 or newer, you can easily use the proc below instead, which is just an improved version of the TclX code:
======
proc rglob {dirlist globlist} {
set result {}
set recurse {}
foreach dir $dirlist {
if ![file isdirectory $dir] {
return -code error "'$dir' is not a directory"
}
foreach pattern $globlist {
lappend result {*}[glob -nocomplain -directory $dir -- $pattern]
}
foreach file [glob -nocomplain -directory $dir -- *] {
set file [file join $dir $file]
if [file isdirectory $file] {
set fileTail [file tail $file]
if {!($fileTail eq "." || $fileTail eq "..")} {
lappend recurse $file
}
}
}
}
if {[llength $recurse] > 0} {
lappend result {*}[rglob $recurse $globlist]
}
return $result
}
======
----
[tjk] The above code doesn't work (at least for me). Here is a version that works and include an exclusion list. This version doesn't take a list of directories as the first argument but I can't think of a good reason that it should.
======
proc rglob { dirpath patterns {exclude_pats {}} } {
set rlist {}
set exclude [glob -nocomplain -types f -directory ${dirpath} {*}${exclude_pats}]
foreach fpath [glob -nocomplain -types f -directory ${dirpath} {*}${patterns}] {
if { ${fpath} ni ${exclude} } {
lappend rlist ${fpath}
}
}
foreach dir [glob -nocomplain -types d -directory ${dirpath} *] {
lappend rlist {*}[rglob ${dir} ${patterns} ${exclude_pats}]
}
return ${rlist}
}
======
------
[RFox] Even more powerful is the fileutil::find command which uses a 'visitor pattern' to allow you to filter the files found in a directory tree via a script. since the script could have side effects, this also subsumes the [for_recursive_glob] functionality.
======
<<categories>>Command | TclX}} CALL {my revision recursive_glob} CALL {::oo::Obj2109665 process revision/recursive_glob} CALL {::oo::Obj2109663 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