Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the --has and --hasnot options to the find-fossil-cgis.tcl script. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ccb7cc4ecd6ed7797b7c7125134192de |
User & Date: | drh 2025-03-29 00:22:52.988 |
Context
2025-03-29
| ||
10:44 | New command-line options for find-fossil-cgis.tcl: --print, --symlink, and -v. ... (check-in: 609f885a02 user: drh tags: trunk) | |
00:22 | Add the --has and --hasnot options to the find-fossil-cgis.tcl script. ... (check-in: ccb7cc4ecd user: drh tags: trunk) | |
00:15 | (Typo) correction to www/changes.wiki. ... (check-in: 71e1ef3384 user: brickviking tags: trunk) | |
Changes
Changes to tools/find-fossil-cgis.tcl.
1 2 3 4 5 6 7 | #!/usr/bin/tclsh # # This script scans a directory hierarchy looking for Fossil CGI files - # the files that are used to launch Fossil as a CGI program. For each # such file found, in prints the name of the file and then prints the # file content, indented. # | | > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/usr/bin/tclsh # # This script scans a directory hierarchy looking for Fossil CGI files - # the files that are used to launch Fossil as a CGI program. For each # such file found, in prints the name of the file and then prints the # file content, indented. # # tclsh find-fossil-cgis.tcl [OPTIONS] $DIRECTORY # # The argument is the directory from which to begin the search. # # OPTIONS can be zero or more of the following: # # --has REGEXP Only show the CGI if the body matches REGEXP. # May be repeated multiple times, in which case # all must match. # # --hasnot REGEXP Only show the CGI if it does NOT match the # REGEXP. # # Find the CGIs in directory $dir. Invoke recursively to # scan subdirectories. # proc find_in_one_dir {dir} { global HAS HASNOT foreach obj [lsort [glob -nocomplain -directory $dir *]] { if {[file isdir $obj]} { find_in_one_dir $obj continue } if {![file isfile $obj]} continue if {[file size $obj]>5000} continue if {![file readable $obj]} continue set fd [open $obj rb] set txt [read $fd] close $fd if {![string match #!* $txt]} continue if {![regexp {fossil} $txt]} continue if {![regexp {\nrepository: } $txt] && ![regexp {\ndirectory: } $txt] && ![regexp {\nredirect: } $txt]} continue set ok 1 foreach re $HAS { if {![regexp $re $txt]} {set ok 0; break;} } if {!$ok} continue foreach re $HASNOT { if {[regexp $re $txt]} {set ok 0; break;} } if {!$ok} continue # # At this point assume we have found a CGI file. # puts $obj regsub -all {\n} [string trim $txt] "\n " out puts " $out" } } set HAS [list] set HASNOT [list] set N [llength $argv] for {set i 0} {$i<$N} {incr i} { set dir [lindex $argv $i] if {($dir eq "-has" || $dir eq "--has") && $i<[expr {$N-1}]} { incr i lappend HAS [lindex $argv $i] continue } if {($dir eq "-hasnot" || $dir eq "--hasnot") && $i<[expr {$N-1}]} { incr i lappend HASNOT [lindex $argv $i] continue } find_in_one_dir $dir } |