Files
modules/init/ruby.rb.in
Xavier Delaruelle 6ce8fda40a Support for Ruby "shell"
And adapt documentation, installation and testsuite.
2017-08-09 00:19:31 +02:00

30 lines
872 B
Ruby

class ENVModule
def ENVModule.module(*args)
if args[0].kind_of?(Array) then
args = args[0].join(' ')
else
args = args.join(' ')
end
eval `@TCLSH@ @libexecdir@/modulecmd.tcl ruby #{args}`
end
end
ENV['MODULESHOME'] = '@prefix@'
if !ENV.has_key?('MODULEPATH') then
if File.readable?('@initdir@/.modulespath') then
ENV['MODULEPATH'] = File.open('@initdir@/.modulespath','r').readlines.reject {|e| e =~ /^(\s*#|$)/}.select {|s| s.sub!(/^\s*(.*?)[\s#].*$/, '\\1').chop! }.join(':')
else
ENV['MODULEPATH'] = ''
end
end
if !ENV.has_key?('LOADEDMODULES') then
ENV['LOADEDMODULES'] = ''
end
# load modulerc only if module environment is empty
if File.readable?('@initdir@/modulerc') and ENV['MODULEPATH'].empty? and ENV['LOADEDMODULES'].empty? then
ENVModule.module('source', '@initdir@/modulerc')
end