Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Modules 5.7.0 (not yet released)
* Improve the performance of the module’s column output by removing the costly
optimization that attempts to fit more columns within the available screen
width. (fix issue #622)
* Fix superseding definition of ``source`` Tcl command when
:mconfig:`source_cache` configuration option is enabled to support
``-encoding`` option. (fix issue #627)


.. _5.6 release notes:
Expand Down
18 changes: 17 additions & 1 deletion tcl/mfcmd.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,23 @@ proc unique-name-conflict {} {
conflict {*}$root_name_list
}

proc sourceModfileCmd {itrp filename} {
proc sourceModfileCmd {itrp args} {
# argument parsing: catch encoding arg but ignore it
switch -- [llength $args] {
1 {}
3 {
set option [lindex $args 0]
if {$option ne {-encoding}} {
knerror "Invalid option '$option'"
}
}
default {
knerror {wrong # args: should be "source ?-encoding? ?encodingName?\
fileName"}
}
}
set filename [lindex $args end]

if {![info exists ::source_cache($filename)]} {
set ::source_cache($filename) [readFile $filename]
}
Expand Down
12 changes: 12 additions & 0 deletions testsuite/modulefiles.4/source/1.0
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ if {[info exists env(TESTSUITE_SOURCE_CACHE)]} {
source ../path/to/unk
setenv VAR bar
}
arg1 {
source -encoding utf-8 [file dirname $ModulesCurrentModulefile]/source_file
}
bad_arg1 {
source -encoding [file dirname $ModulesCurrentModulefile]/source_file
}
bad_arg2 {
source -foo bar [file dirname $ModulesCurrentModulefile]/source_file
}
bad_arg3 {
source -encoding utf-8 -foo bar [file dirname $ModulesCurrentModulefile]/source_file
}
}
}
3 changes: 3 additions & 0 deletions testsuite/modulefiles.4/source/source_file
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ if {[info exists env(TESTSUITE_SOURCE_CACHE)]} {
break1 {
break
}
arg1 - bad_arg1 - bad_arg2 {
setenv VAR bar
}
}
}
24 changes: 24 additions & 0 deletions testsuite/modules.50-cmds/620-source_cache.exp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,30 @@ testouterr_cmd_re bash {load source/1.0} $ans_load $ts_load

}


# check argument management
setenv_var MODULES_SOURCE_CACHE 1
setenv_var TESTSUITE_SOURCE_CACHE arg1
set ans [list]
lappend ans [list set VAR bar]
lappend ans [list set _LMFILES_ $mp/source/1.0]
lappend ans [list set LOADEDMODULES source/1.0]
testouterr_cmd bash {load source/1.0} $ans {}

setenv_var TESTSUITE_SOURCE_CACHE bad_arg1
set line_num [expr {[cmpversion $tclsh_version 8.6] == -1 ? 2 : 38}]
set tserr [escre [msg_load source/1.0 [msg_moderr {wrong # args: should be "source ?-encoding? ?encodingName? fileName"} {source<EXM>} $mp/source/1.0 $line_num]]]
testouterr_cmd_re bash {load source/1.0} ERR $tserr
set line_num [expr {[cmpversion $tclsh_version 8.6] == -1 ? 2 : 41}]
set tserr [escre [msg_load source/1.0 [msg_moderr {Invalid option '-foo'} {source<EXM>} $mp/source/1.0 $line_num]]]
setenv_var TESTSUITE_SOURCE_CACHE bad_arg2
testouterr_cmd_re bash {load source/1.0} ERR $tserr
setenv_var TESTSUITE_SOURCE_CACHE bad_arg3
set line_num [expr {[cmpversion $tclsh_version 8.6] == -1 ? 2 : 44}]
set tserr [escre [msg_load source/1.0 [msg_moderr {wrong # args: should be "source ?-encoding? ?encodingName? fileName"} {source<EXM>} $mp/source/1.0 $line_num]]]
testouterr_cmd_re bash {load source/1.0} ERR $tserr


# cannot test access if cannot change file permission
if {!$is_file_perms_editable} {
send_user "\tskipping access tests as file permissions cannot be changed\n"
Expand Down
Loading