Files
modules/testsuite/modulefiles/puts/8
Xavier Delaruelle a127870f18 Call real 'puts' command in caller context
To be able to 'puts' content on opened channels, the 'puts' command
should be executed from the modulefile interpreter context. Elsewhere,
master interpreter does not know about the channels opened in its
sub-interpreters.

Adapt interpreter setup to add a command renaming step, to avoid the
puts modulefile alias to overwrite the original puts command. puts
modulefile alias now also pass the caller interpreter reference as first
argument to be able to execute the original puts command, renamed _puts,
within context of this caller interpreter.

Handle wrong argument number error in putsModfileCmd to report an error
for 'puts' command rather '_puts' which should not be known by users.

Add non-regression test to check puts command against opened channel.

Fixes #157
2018-03-01 15:27:04 +01:00

43 lines
966 B
Plaintext

#%Module1.0
##############################################################################
# Modules Revision 3.0
# Providing a flexible user environment
#
# File: puts/%M%
# Revision: %I%
# First Edition: 2018/03/01
# Last Mod.: %U%, %G%
#
# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr
#
# Description: Testuite modulefile
# Command:
# Sub-Command: puts
#
# Invocation: load @M@
# Result: %R{
# }R%
# Comment: %C{
# Check the 'puts' command
# }C%
#
##############################################################################
if {[module-info mode "load"]} {
set fname [file join $::env(TESTSUITEDIR) "puts"]
# write to test file with puts command
set fid [open $fname w]
puts -nonewline $fid "textout1"
puts $fid "textout2"
puts -nonewline $fid "textout3"
close $fid
# read what has been written
set fid [open $fname r]
puts [read $fid]
close $fid
}
setenv testsuite ok