Browse Source

enforce loading of shipped core punk tm modules over modules elsewhere in filesystem

master
Julian Noble 2 years ago
parent
commit
1e819ac8c4
  1. 30
      src/punk86.vfs/lib/app-punk/repl.tcl
  2. 10
      src/punk86.vfs/lib/app-shellspy/shellspy.tcl

30
src/punk86.vfs/lib/app-punk/repl.tcl

@ -28,8 +28,26 @@ proc todo {} {
}
if {[string match "*.vfs/*" [info script]]} {
#src/xxx.vfs/lib/app-punk/repl.tcl
#back 5 gives same level as src folder
#we assume if calling directly into .vfs that the user would prefer to use src/modules - so back only 4
set modulefolder [file dirname [file dirname [file dirname [file dirname [info script]]]]]/modules
tcl::tm::add [pwd]/modules
} else {
set modulefolder [file dirname [info nameofexecutable]]/modules
}
if {[file exists $modulefolder]} {
tcl::tm::add $modulefolder
} else {
puts stderr "Warning unable to find module folder at: $modulefolder"
}
if {[file exists [pwd]/modules]} {
tcl::tm::add [pwd]/modules
}
if {![info exists ::env(SHELL)]} {
set ::env(SHELL) punk86
@ -48,13 +66,21 @@ if {![info exists ::env(TERM)]} {
}
package require Thread
#These are strong dependencies
# - the repl requires Threading and punk,shellfilter,shellrun to call and display properly.
# tm list already indexed - need 'package forget' to find modules based on current tcl::tm::list
package forget shellfilter
package require shellfilter
package forget shellrun
package require shellrun
package require Thread
package forget punk
package require punk
#todo - move to less generic namespace
namespace eval repl {
variable screen_last_chars "" ;#a small sliding append buffer for last char of any screen output to detect \n vs string

10
src/punk86.vfs/lib/app-shellspy/shellspy.tcl

@ -74,15 +74,21 @@ if {[file extension $arg1] in [list .tCl]} {
#lappend auto_path c:/tcl/lib/tcllib1.20
package require Thread
#NOTE: tm package index will probably already have been created so we must use 'package forget' to restrict to current tcl::tm::list path
#Review - effect on load time of wasting a previously created index? better way?
#require core modules only from punk distribution (REVIEW - override option?)
package foreget flagfilter
package require flagfilter
package forget shellfilter
package require shellfilter
package require Thread
package foget punk
package require punk
#restore module paths
set tm_list_now [tcl::tm::list]
foreach p [$original_tm_list] {
foreach p $original_tm_list {
if {$p ni $tm_list_now} {
tcl::tm::add $p
}

Loading…
Cancel
Save