|
|
|
@ -295,16 +295,59 @@ namespace eval punk {
|
|
|
|
|
return [twapi::new_uuid] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
proc ::punk::var {varname {= {}} args} { |
|
|
|
|
|
|
|
|
|
#get last command result that was run through the repl |
|
|
|
|
proc ::punk::get_runchunk {args} { |
|
|
|
|
set argd [punk::args::get_dict { |
|
|
|
|
*opts |
|
|
|
|
-1 -optional 1 -type none |
|
|
|
|
-2 -optional 1 -type none |
|
|
|
|
*values -min 0 -max 0 |
|
|
|
|
} $args] |
|
|
|
|
#todo - make this command run without truncating previous runchunks |
|
|
|
|
set runchunks [tsv::array names repl runchunks-*] |
|
|
|
|
|
|
|
|
|
set sortlist [list] |
|
|
|
|
foreach cname $runchunks { |
|
|
|
|
set num [lindex [split $cname -] 1] |
|
|
|
|
lappend sortlist [list $num $cname] |
|
|
|
|
} |
|
|
|
|
set sorted [lsort -index 0 -integer $sortlist] |
|
|
|
|
set chunkname [lindex $sorted end-1 1] |
|
|
|
|
set runlist [tsv::get repl $chunkname] |
|
|
|
|
#puts stderr "--$runlist" |
|
|
|
|
if {![llength $runlist]} { |
|
|
|
|
return "" |
|
|
|
|
} else { |
|
|
|
|
return [lindex [lsearch -inline -index 0 $runlist result] 1] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
interp alias {} _ {} ::punk::get_runchunk |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::punk::var {varname {= _=.=_} args} { |
|
|
|
|
upvar $varname the_var |
|
|
|
|
if {${=} == "="} { |
|
|
|
|
if {[llength $args] > 1} { |
|
|
|
|
set the_var [uplevel 1 $args] |
|
|
|
|
} else { |
|
|
|
|
set the_var [lindex $args 0] |
|
|
|
|
switch -exact -- ${=} { |
|
|
|
|
= { |
|
|
|
|
if {[llength $args] > 1} { |
|
|
|
|
set the_var $args |
|
|
|
|
} else { |
|
|
|
|
set the_var [lindex $args 0] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.= { |
|
|
|
|
if {[llength $args] > 1} { |
|
|
|
|
set the_var [uplevel 1 $args] |
|
|
|
|
} else { |
|
|
|
|
set the_var [uplevel 1 [lindex $args 0]] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
_=.=_ { |
|
|
|
|
set the_var |
|
|
|
|
} |
|
|
|
|
default { |
|
|
|
|
set the_var [list ${=} {*}$args] |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
set the_var |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
proc src {args} { |
|
|
|
@ -7302,6 +7345,15 @@ namespace eval punk {
|
|
|
|
|
set usetable 1 |
|
|
|
|
if {$usetable} { |
|
|
|
|
set t [textblock::class::table new -show_hseps 0 -show_header 1 -ansiborder_header [a+ web-green]] |
|
|
|
|
if {"windows" eq $::tcl_platform(platform)} { |
|
|
|
|
#If any env vars have been set to empty string - this is considered a deletion of the variable on windows. |
|
|
|
|
#The Tcl ::env array is linked to the underlying process view of the environment |
|
|
|
|
#- but info exists ::env(var) can misreport as true if it has been deleted by setting to empty string rather than using unset. |
|
|
|
|
#an 'array get' will resynchronise. |
|
|
|
|
#Even if an env variable didn't exist before - setting it to empty string can get it to this inconsistent state. |
|
|
|
|
array get ::env |
|
|
|
|
} |
|
|
|
|
#do an array read on ::env |
|
|
|
|
foreach {v vinfo} $punkenv_config { |
|
|
|
|
if {[info exists ::env($v)]} { |
|
|
|
|
set c2 [set ::env($v)] |
|
|
|
|