|
|
|
@ -4123,10 +4123,9 @@ namespace eval punk {
|
|
|
|
|
set files [lsort $files] ;#todo natsort |
|
|
|
|
return [list dirs $dirs vfs $vfs files $files location $location] |
|
|
|
|
} |
|
|
|
|
proc dirfiles {{glob ""}} { |
|
|
|
|
|
|
|
|
|
proc dirfiles_dict_as_lines {contents} { |
|
|
|
|
package require overtype |
|
|
|
|
set contents [dirfiles_dict $glob] |
|
|
|
|
set dirs [dict get $contents dirs] |
|
|
|
|
set files [dict get $contents files] |
|
|
|
|
set vfs [dict get $contents vfs] |
|
|
|
@ -4150,6 +4149,11 @@ namespace eval punk {
|
|
|
|
|
return [list_as_lines $displaylist] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
proc dirfiles {{glob ""}} { |
|
|
|
|
set contents [dirfiles_dict $glob] |
|
|
|
|
return [dirfiles_dict_as_lines $contents] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#experimental... leading colon makes it hard (impossible?) to call directly |
|
|
|
|
proc ns/ {args} { |
|
|
|
|
variable ns_current |
|
|
|
@ -4220,9 +4224,14 @@ namespace eval punk {
|
|
|
|
|
if {![llength $args]} { |
|
|
|
|
#ls is too slow even over a fairly low-latency network |
|
|
|
|
#set out [runout -n ls -aFC] |
|
|
|
|
set result [pwd] |
|
|
|
|
set matchinfo [punk::dirfiles_dict] |
|
|
|
|
set dircount [llength [dict get $matchinfo dirs]] |
|
|
|
|
set filecount [llength [dict get $matchinfo files]] |
|
|
|
|
set location [file normalize [dict get $matchinfo location]] |
|
|
|
|
#result for glob is count of matches - use dirfiles etc for script access to results |
|
|
|
|
set result [list location $location dircount $dircount filecount $filecount] |
|
|
|
|
if {$::repl::running} { |
|
|
|
|
set out [punk::dirfiles] |
|
|
|
|
set out [punk::dirfiles_dict_as_lines $matchinfo] |
|
|
|
|
|
|
|
|
|
#puts stdout $out |
|
|
|
|
#puts stderr [a+ white]$out[a+] |
|
|
|
@ -4231,7 +4240,7 @@ namespace eval punk {
|
|
|
|
|
lappend chunklist [list result $result] |
|
|
|
|
set ::punk::last_run_display $chunklist |
|
|
|
|
|
|
|
|
|
repl::term::set_console_title [file normalize $result] |
|
|
|
|
repl::term::set_console_title $location |
|
|
|
|
} |
|
|
|
|
return $result |
|
|
|
|
} else { |
|
|
|
@ -4265,6 +4274,27 @@ namespace eval punk {
|
|
|
|
|
set path $curdir/$a1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if {![llength $atail] && ([string first "*" [file tail $path]] >= 0) || ([string first "?" [file tail $path]] >= 0)} { |
|
|
|
|
#no more segments and we have a globchar at the end |
|
|
|
|
set matchinfo [punk::dirfiles_dict [file tail $path]] |
|
|
|
|
set dircount [llength [dict get $matchinfo dirs]] |
|
|
|
|
set filecount [llength [dict get $matchinfo files]] |
|
|
|
|
set location [file normalize [dict get $matchinfo location]] |
|
|
|
|
#result for glob is count of matches - use dirfiles etc for script access to results |
|
|
|
|
set result [list location $location dircount $dircount filecount $filecount] |
|
|
|
|
if {$::repl::running} { |
|
|
|
|
set out [punk::dirfiles_dict_as_lines $matchinfo] |
|
|
|
|
set chunklist [list] |
|
|
|
|
lappend chunklist [list stdout "[a+ white light]$out[a+]\n"] |
|
|
|
|
lappend chunklist [list result $result] |
|
|
|
|
set ::punk::last_run_display $chunklist |
|
|
|
|
|
|
|
|
|
repl::term::set_console_title $location |
|
|
|
|
} |
|
|
|
|
return $result |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if {[file type $path] eq "file"} { |
|
|
|
|
if {[string tolower [file extension $path]] in [list ".tcl" ".tm"]} { |
|
|
|
|
set newargs $atail |
|
|
|
@ -4292,15 +4322,20 @@ namespace eval punk {
|
|
|
|
|
set path ../[file join {*}$args] |
|
|
|
|
} |
|
|
|
|
cd $path |
|
|
|
|
#set out [runout -n ls -aFC] |
|
|
|
|
set out [punk::dirfiles] |
|
|
|
|
set result [pwd] |
|
|
|
|
set matchinfo [punk::dirfiles_dict] |
|
|
|
|
set dircount [llength [dict get $matchinfo dirs]] |
|
|
|
|
set filecount [llength [dict get $matchinfo files]] |
|
|
|
|
set location [file normalize [dict get $matchinfo location]] |
|
|
|
|
#result for glob is count of matches - use dirfiles etc for script access to results |
|
|
|
|
set result [list location $location dircount $dircount filecount $filecount] |
|
|
|
|
|
|
|
|
|
if {$::repl::running} { |
|
|
|
|
set out [punk::dirfiles_dict_as_lines $matchinfo] |
|
|
|
|
#return $out\n[pwd] |
|
|
|
|
set chunklist [list] |
|
|
|
|
lappend chunklist [list stdout "[a+ white light]$out[a+]\n"] |
|
|
|
|
lappend chunklist [list result $result] |
|
|
|
|
set ::punk::last_run_display $chunklist |
|
|
|
|
if {$::repl::running} { |
|
|
|
|
repl::term::set_console_title $result |
|
|
|
|
} |
|
|
|
|
return $result |
|
|
|
|