From 91380cdbee8137f8a67e845fbda0858e88e37c9b Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Wed, 21 Jul 2021 14:16:56 +0200 Subject: [PATCH] init: remove compat version-related code --- init/.gitignore | 2 -- init/bash.in | 40 ---------------------------------- init/bash_completion.in | 43 ------------------------------------- init/cmake.in | 18 ---------------- init/csh.in | 37 -------------------------------- init/fish.in | 2 -- init/ksh.in | 38 -------------------------------- init/perl.pm.in | 12 ----------- init/profile-compat.csh.in | 8 ------- init/profile-compat.sh.in | 11 ---------- init/python.py.in | 9 -------- init/ruby.rb.in | 17 --------------- init/sh.in | 42 ------------------------------------ init/zsh.in | 44 -------------------------------------- 14 files changed, 323 deletions(-) delete mode 100644 init/profile-compat.csh.in delete mode 100644 init/profile-compat.sh.in diff --git a/init/.gitignore b/init/.gitignore index aa5dd179..5b5cd41b 100644 --- a/init/.gitignore +++ b/init/.gitignore @@ -19,5 +19,3 @@ /modulespath /profile.sh /profile.csh -/profile-compat.sh -/profile-compat.csh diff --git a/init/bash.in b/init/bash.in index e2e2d4da..a6a1c31d 100644 --- a/init/bash.in +++ b/init/bash.in @@ -53,17 +53,6 @@ _mlret=$? if [ $_mlret -eq 0 ]; then eval "$_mlcode" -@compatversion@ # redefine module command if compat version has been activated -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat -@compatversion@ export MODULES_CMD -@compatversion@ if [ -t 2 ]; then -@compatversion@ _module_raw() { eval `@libexecdir@/modulecmd-compat bash $*`; } -@compatversion@ else -@compatversion@ module() { eval `@libexecdir@/modulecmd-compat bash $*`; } -@compatversion@ fi -@compatversion@ fi -@compatversion@ # export functions to get them defined in sub-shells if [ -t 2 ]; then export -f _module_raw @@ -73,35 +62,6 @@ if [ $_mlret -eq 0 ]; then export -f ml fi -@compatversion@ # define function to switch between C and Tcl versions of Modules -@compatversion@ switchml() { -@compatversion@ typeset swfound=1 -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ typeset swname='main' -@compatversion@ if [ -e @libexecdir@/modulecmd.tcl ]; then -@compatversion@ typeset swfound=0 -@compatversion@ unset MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ else -@compatversion@ typeset swname='compatibility' -@compatversion@ if [ -e @libexecdir@/modulecmd-compat ]; then -@compatversion@ typeset swfound=0 -@compatversion@ MODULES_USE_COMPAT_VERSION=1 -@compatversion@ export MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ fi -@compatversion@ -@compatversion@ # switch version only if command found -@compatversion@ if [ $swfound -eq 0 ]; then -@compatversion@ echo "Switching to Modules $swname version" -@compatversion@ source @initdir@/bash -@compatversion@ else -@compatversion@ echo "Cannot switch to Modules $swname version, command not found" -@compatversion@ return 1 -@compatversion@ fi -@compatversion@ } -@compatversion@ export -f switchml -@compatversion@ # enable completion only in interactive mode if [ ${BASH_VERSINFO:-0} -ge 3 ] && [[ $- =~ i ]] && [ -r @initdir@/bash_completion ]; then diff --git a/init/bash_completion.in b/init/bash_completion.in index 5036e9df..55771b75 100644 --- a/init/bash_completion.in +++ b/init/bash_completion.in @@ -54,48 +54,6 @@ _module_long_arg_list() { done } -@compatversion@# define completion relative to active version -@compatversion@if [ "$MODULES_USE_COMPAT_VERSION" = '1' ]; then -@compatversion@_module() { -@compatversion@ local cur="$2" prev="$3" cmds opts -@compatversion@ -@compatversion@ COMPREPLY=() -@compatversion@ -@compatversion@ cmds="add apropos avail clear display del help\ -@compatversion@ initadd initclear initlist initprepend initrm initswitch\ -@compatversion@ keyword list load purge refresh remove rm show swap switch\ -@compatversion@ unload unuse update use whatis" -@compatversion@ -@compatversion@ opts="-c -f -h -i -l -s -t -u -v -H -V\ -@compatversion@ --create --force --help --human --icase\ -@compatversion@ --long --silent --terse --userlvl --verbose --version" -@compatversion@ -@compatversion@ case "$prev" in -@compatversion@ add|load) COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") );; -@compatversion@ rm|del|remove|unload|switch|swap) -@compatversion@ COMPREPLY=( $(IFS=: compgen -W "${LOADEDMODULES}" -- "$cur") );; -@compatversion@ unuse) COMPREPLY=( $(IFS=: compgen -W "${MODULEPATH}" -- "$cur") );; -@compatversion@ use|*-a*) ;; # let readline handle the completion -@compatversion@ -u|--userlvl) COMPREPLY=( $(compgen -W "novice expert advanced" -- "$cur") );; -@compatversion@ av*|disp*|help|show|whatis) -@compatversion@ COMPREPLY=( $(compgen -W "$(_module_avail)" -- "$cur") );; -@compatversion@ *) if test $COMP_CWORD -gt 2 -@compatversion@ then -@compatversion@ _module_long_arg_list "$cur" -@compatversion@ else -@compatversion@ case "$cur" in -@compatversion@ # The mappings below are optional abbreviations for convenience -@compatversion@ ls) COMPREPLY="list";; # map ls -> list -@compatversion@ r*) COMPREPLY="rm";; # also covers 'remove' -@compatversion@ sw*) COMPREPLY="switch";; -@compatversion@ -@compatversion@ -*) COMPREPLY=( $(compgen -W "$opts" -- "$cur") );; -@compatversion@ *) COMPREPLY=( $(compgen -W "$cmds" -- "$cur") );; -@compatversion@ esac -@compatversion@ fi;; -@compatversion@ esac -@compatversion@} -@compatversion@else _module() { local cur="$2" prev="$3" cmds opts @@ -214,5 +172,4 @@ if $(type -t ml >/dev/null); then } complete -o default -F _ml ml fi -@compatversion@fi complete -o default -F _module module diff --git a/init/cmake.in b/init/cmake.in index b1d5148f..68075e33 100644 --- a/init/cmake.in +++ b/init/cmake.in @@ -33,21 +33,3 @@ if(EXISTS ${tempfile_name}) include(${tempfile_name}) file(REMOVE ${tempfile_name}) endif() -@compatversion@ -@compatversion@# redefine module command if compat version has been activated -@compatversion@if("$ENV{MODULES_USE_COMPAT_VERSION}" STREQUAL "1") -@compatversion@ set(ENV{MODULES_CMD} "@libexecdir@/modulecmd-compat") -@compatversion@ function(module) -@compatversion@ execute_process(COMMAND mktemp -t moduleinit.cmake.XXXXXXXXXXXX -@compatversion@ OUTPUT_VARIABLE tempfile_name -@compatversion@ OUTPUT_STRIP_TRAILING_WHITESPACE) -@compatversion@ execute_process(COMMAND @libexecdir@/modulecmd-compat cmake ${ARGV} -@compatversion@ OUTPUT_FILE ${tempfile_name}) -@compatversion@ if(EXISTS ${tempfile_name}) -@compatversion@ include(${tempfile_name}) -@compatversion@ file(REMOVE ${tempfile_name}) -@compatversion@ endif() -@compatversion@ # return value as done on new main version -@compatversion@ set(module_result TRUE PARENT_SCOPE) -@compatversion@ endfunction(module) -@compatversion@endif() diff --git a/init/csh.in b/init/csh.in index a96d1eb2..8d2adf9c 100644 --- a/init/csh.in +++ b/init/csh.in @@ -4,45 +4,8 @@ eval "`@TCLSH@ @libexecdir@/modulecmd.tcl @SHELLNAME@ autoinit`" # no environment alteration if the above autoinit command failed if ( $status == 0 ) then -@compatversion@ # clarify compat version is not enabled for below tests -@compatversion@ if ( ! $?MODULES_USE_COMPAT_VERSION ) then -@compatversion@ setenv MODULES_USE_COMPAT_VERSION 0 -@compatversion@ endif -@compatversion@ -@compatversion@ # redefine module command if compat version has been activated -@compatversion@ if ( "$MODULES_USE_COMPAT_VERSION" == '1' ) then -@compatversion@ setenv MODULES_CMD @libexecdir@/modulecmd-compat ; -@compatversion@ if ( $?histchars && $?prompt ) alias module 'set _histchars = $histchars; unset histchars; set _prompt=$prompt:q; set prompt=""; eval `@libexecdir@/modulecmd-compat @SHELLNAME@ \!*`; set _exit="$status"; set histchars = $_histchars; unset _histchars; set prompt=$_prompt:q; unset _prompt; test 0 = $_exit' ; -@compatversion@ if ( $?histchars && ! $?prompt ) alias module 'set _histchars = $histchars; unset histchars; eval `@libexecdir@/modulecmd-compat @SHELLNAME@ \!*`; set _exit="$status"; set histchars = $_histchars; unset _histchars; test 0 = $_exit' ; -@compatversion@ if ( ! $?histchars && $?prompt ) alias module 'set _prompt=$prompt:q; set prompt=""; eval `@libexecdir@/modulecmd-compat @SHELLNAME@ \!*`; set _exit="$status"; set prompt=$_prompt:q;unset _prompt; test 0 = $_exit' ; -@compatversion@ if ( ! $?histchars && ! $?prompt ) alias module 'eval `@libexecdir@/modulecmd-compat @SHELLNAME@ \!*`' ; -@compatversion@ endif -@compatversion@ -@compatversion@ # define function to switch between C and Tcl versions of Modules -@compatversion@ set switchml_defined="`alias switchml`" -@compatversion@ if ( "$switchml_defined" == '' ) then -@compatversion@ alias switchml 'set swfound=1; \\ -@compatversion@ if ( ! $?MODULES_USE_COMPAT_VERSION ) setenv MODULES_USE_COMPAT_VERSION 0; \\ -@compatversion@ if ( "$MODULES_USE_COMPAT_VERSION" == "1" ) set swname="main"; \\ -@compatversion@ if ( "$MODULES_USE_COMPAT_VERSION" == "1" && -e @libexecdir@/modulecmd.tcl ) set swfound=0; \\ -@compatversion@ if ( "$MODULES_USE_COMPAT_VERSION" != "1" ) set swname="compatibility"; \\ -@compatversion@ if ( "$MODULES_USE_COMPAT_VERSION" != "1" && -e @libexecdir@/modulecmd-compat ) set swfound=0; \\ -@compatversion@ if ( $swfound == 0 && $swname == "main" ) setenv MODULES_USE_COMPAT_VERSION 0; \\ -@compatversion@ if ( $swfound == 0 && $swname == "compatibility" ) setenv MODULES_USE_COMPAT_VERSION 1; \\ -@compatversion@ if ( $swfound == 0 ) echo "Switching to Modules $swname version"; \\ -@compatversion@ if ( $swfound == 0 ) source @initdir@/@SHELLNAME@; \\ -@compatversion@ if ( $swfound != 0 ) echo "Cannot switch to Modules $swname version, command not found"; \\ -@compatversion@ unset swfound swname;' -@compatversion@ endif -@compatversion@ unset switchml_defined -@compatversion@ if ( $?tcsh && $?prompt && -r @initdir@/tcsh_completion ) then -@compatversion@ if ( "$MODULES_USE_COMPAT_VERSION" != '1' ) then source @initdir@/tcsh_completion -@compatversion@ else -@compatversion@ # no completion support on compat version -@compatversion@ uncomplete module -@compatversion@ endif endif @setbinpath@ @setbinpath@ if ( ":${PATH}:" !~ '*:@bindir@:*' ) then diff --git a/init/fish.in b/init/fish.in index 55bac716..083bf81e 100644 --- a/init/fish.in +++ b/init/fish.in @@ -31,8 +31,6 @@ if [ $status -eq 0 ] end end -@compatversion@ # no switchml definition since there is no Fish support in C version -@compatversion@ @setbinpath@ if not contains @bindir@ $PATH @setbinpath@@prependbinpath@ set -xg PATH @bindir@ $PATH @setbinpath@@appendbinpath@ set -xg PATH $PATH @bindir@ diff --git a/init/ksh.in b/init/ksh.in index 7a318925..3a85cb6d 100644 --- a/init/ksh.in +++ b/init/ksh.in @@ -53,44 +53,6 @@ _mlret=$? if [ $_mlret -eq 0 ]; then eval "$_mlcode" -@compatversion@ # redefine module command if compat version has been activated -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat -@compatversion@ export MODULES_CMD -@compatversion@ if [ -t 2 ]; then -@compatversion@ _module_raw() { eval `@libexecdir@/modulecmd-compat ksh $*`; } -@compatversion@ else -@compatversion@ module() { eval `@libexecdir@/modulecmd-compat ksh $*`; } -@compatversion@ fi -@compatversion@ fi -@compatversion@ -@compatversion@ # define function to switch between C and Tcl versions of Modules -@compatversion@ switchml() { -@compatversion@ typeset swfound=1 -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ typeset swname='main' -@compatversion@ if [ -e @libexecdir@/modulecmd.tcl ]; then -@compatversion@ typeset swfound=0 -@compatversion@ unset MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ else -@compatversion@ typeset swname='compatibility' -@compatversion@ if [ -e @libexecdir@/modulecmd-compat ]; then -@compatversion@ typeset swfound=0 -@compatversion@ MODULES_USE_COMPAT_VERSION=1 -@compatversion@ export MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ fi -@compatversion@ -@compatversion@ # switch version only if command found -@compatversion@ if [ $swfound -eq 0 ]; then -@compatversion@ echo "Switching to Modules $swname version" -@compatversion@ . @initdir@/ksh -@compatversion@ else -@compatversion@ echo "Cannot switch to Modules $swname version, command not found" -@compatversion@ return 1 -@compatversion@ fi -@compatversion@ } @setbinpath@ @setbinpath@ _mlinstr=":$PATH:" @setbinpath@ if [ "${_mlinstr#*:@bindir@:}" = "$_mlinstr" ]; then diff --git a/init/perl.pm.in b/init/perl.pm.in index e4a506ff..876f5702 100644 --- a/init/perl.pm.in +++ b/init/perl.pm.in @@ -26,16 +26,4 @@ @quarantinesupport@# clean temp variable used to setup quarantine @quarantinesupport@undef $_mlre; @quarantinesupport@ -@compatversion@# redefine module command if compat version has been activated -@compatversion@if ($ENV{'MODULES_USE_COMPAT_VERSION'} eq '1') { -@compatversion@ $ENV{'MODULES_CMD'} = '@libexecdir@/modulecmd-compat'; -@compatversion@ { no warnings 'redefine'; -@compatversion@ *module = sub { -@compatversion@ eval `@libexecdir@/modulecmd-compat perl @_`; -@compatversion@ # return value as done on new main version -@compatversion@ return 1; -@compatversion@ }; -@compatversion@ } -@compatversion@} -@compatversion@ 1; diff --git a/init/profile-compat.csh.in b/init/profile-compat.csh.in deleted file mode 100644 index 50ff4be6..00000000 --- a/init/profile-compat.csh.in +++ /dev/null @@ -1,8 +0,0 @@ -# initialize compatibility version rather main version -setenv MODULES_USE_COMPAT_VERSION 1 - -if ($?tcsh) then - source @initdir@/tcsh -else - source @initdir@/csh -endif diff --git a/init/profile-compat.sh.in b/init/profile-compat.sh.in deleted file mode 100644 index fd2be1f6..00000000 --- a/init/profile-compat.sh.in +++ /dev/null @@ -1,11 +0,0 @@ -# initialize compatibility version rather main version -MODULES_USE_COMPAT_VERSION=1 -export MODULES_USE_COMPAT_VERSION - -shell=$(@BASENAME@ $(@PS@ -p $$ -ocomm=)) - -if [ -f @initdir@/$shell ]; then - source @initdir@/$shell -else - source @initdir@/sh -fi diff --git a/init/python.py.in b/init/python.py.in index 23213bcd..837f1807 100644 --- a/init/python.py.in +++ b/init/python.py.in @@ -25,12 +25,3 @@ import os, re, subprocess @quarantinesupport@ @quarantinesupport@# clean temp variable used to setup quarantine @quarantinesupport@del _mlre -@compatversion@ -@compatversion@# redefine module command if compat version has been activated -@compatversion@if 'MODULES_USE_COMPAT_VERSION' in os.environ and os.environ['MODULES_USE_COMPAT_VERSION'] == '1': -@compatversion@ os.environ['MODULES_CMD'] = '@libexecdir@/modulecmd-compat' -@compatversion@ # set module command in accordance with active version -@compatversion@ def module(command, *arguments): -@compatversion@ exec(subprocess.Popen(['@libexecdir@/modulecmd-compat', 'python', command] + list(arguments), stdout=subprocess.PIPE).communicate()[0]) -@compatversion@ # return value as done on new main version -@compatversion@ return True diff --git a/init/ruby.rb.in b/init/ruby.rb.in index 1d96c6b2..0a30e28e 100644 --- a/init/ruby.rb.in +++ b/init/ruby.rb.in @@ -24,20 +24,3 @@ # for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init config files) @quarantinesupport@eval `#{_mlre}@TCLSH@ @libexecdir@/modulecmd.tcl ruby autoinit` @notquarantinesupport@eval `@TCLSH@ @libexecdir@/modulecmd.tcl ruby autoinit` -@compatversion@ -@compatversion@# redefine module command if compat version has been activated -@compatversion@if ENV['MODULES_USE_COMPAT_VERSION'] == '1' then -@compatversion@ ENV['MODULES_CMD'] = '@libexecdir@/modulecmd-compat' -@compatversion@ class ENVModule -@compatversion@ def ENVModule.module(*args) -@compatversion@ if args[0].kind_of?(Array) then -@compatversion@ args = args[0].join(' ') -@compatversion@ else -@compatversion@ args = args.join(' ') -@compatversion@ end -@compatversion@ eval `@libexecdir@/modulecmd-compat ruby #{args}` -@compatversion@ # return value as done on new main version -@compatversion@ return true -@compatversion@ end -@compatversion@ end -@compatversion@end diff --git a/init/sh.in b/init/sh.in index 6bf3169b..2d49dc1e 100644 --- a/init/sh.in +++ b/init/sh.in @@ -53,17 +53,6 @@ _mlret=$? if [ $_mlret -eq 0 ]; then eval "$_mlcode" -@compatversion@ # redefine module command if compat version has been activated -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat -@compatversion@ export MODULES_CMD -@compatversion@ if [ -t 2 ]; then -@compatversion@ _module_raw() { eval `@libexecdir@/modulecmd-compat sh $*`; } -@compatversion@ else -@compatversion@ module() { eval `@libexecdir@/modulecmd-compat sh $*`; } -@compatversion@ fi -@compatversion@ fi -@compatversion@ # if sh is bash, export functions to get them defined in sub-shells if [ "${BASH:-}" != '' ]; then if [ -t 2 ]; then @@ -75,37 +64,6 @@ if [ $_mlret -eq 0 ]; then fi fi -@compatversion@ # define function to switch between C and Tcl versions of Modules -@compatversion@ switchml() { -@compatversion@ swfound=1 -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ swname='main' -@compatversion@ if [ -e @libexecdir@/modulecmd.tcl ]; then -@compatversion@ swfound=0 -@compatversion@ unset MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ else -@compatversion@ swname='compatibility' -@compatversion@ if [ -e @libexecdir@/modulecmd-compat ]; then -@compatversion@ swfound=0 -@compatversion@ MODULES_USE_COMPAT_VERSION=1 -@compatversion@ export MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ fi -@compatversion@ -@compatversion@ # switch version only if command found -@compatversion@ if [ $swfound -eq 0 ]; then -@compatversion@ echo "Switching to Modules $swname version" -@compatversion@ . @initdir@/sh -@compatversion@ else -@compatversion@ echo "Cannot switch to Modules $swname version, command not found" -@compatversion@ return 1 -@compatversion@ fi -@compatversion@ } -@compatversion@ if [ "${BASH:-}" != '' ]; then -@compatversion@ export -f switchml -@compatversion@ fi -@compatversion@ @setbinpath@ case ":$PATH:" in @setbinpath@ *:@bindir@:*) ;; @setbinpath@@prependbinpath@ *) PATH=@bindir@${PATH:+:}$PATH diff --git a/init/zsh.in b/init/zsh.in index 75233887..52f1a6fc 100644 --- a/init/zsh.in +++ b/init/zsh.in @@ -53,55 +53,11 @@ _mlret=$? if [ $_mlret -eq 0 ]; then eval "$_mlcode" -@compatversion@ # redefine module command if compat version has been activated -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ MODULES_CMD=@libexecdir@/modulecmd-compat -@compatversion@ export MODULES_CMD -@compatversion@ if [ -t 2 ]; then -@compatversion@ _module_raw() { eval `@libexecdir@/modulecmd-compat zsh $*`; } -@compatversion@ else -@compatversion@ module() { eval `@libexecdir@/modulecmd-compat zsh $*`; } -@compatversion@ fi -@compatversion@ fi -@compatversion@ -@compatversion@ # define function to switch between C and Tcl versions of Modules -@compatversion@ switchml() { -@compatversion@ typeset swfound=1 -@compatversion@ if [ "${MODULES_USE_COMPAT_VERSION:-0}" = '1' ]; then -@compatversion@ typeset swname='main' -@compatversion@ if [ -e @libexecdir@/modulecmd.tcl ]; then -@compatversion@ typeset swfound=0 -@compatversion@ unset MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ else -@compatversion@ typeset swname='compatibility' -@compatversion@ if [ -e @libexecdir@/modulecmd-compat ]; then -@compatversion@ typeset swfound=0 -@compatversion@ MODULES_USE_COMPAT_VERSION=1 -@compatversion@ export MODULES_USE_COMPAT_VERSION -@compatversion@ fi -@compatversion@ fi -@compatversion@ -@compatversion@ # switch version only if command found -@compatversion@ if [ $swfound -eq 0 ]; then -@compatversion@ echo "Switching to Modules $swname version" -@compatversion@ source @initdir@/zsh -@compatversion@ else -@compatversion@ echo "Cannot switch to Modules $swname version, command not found" -@compatversion@ return 1 -@compatversion@ fi -@compatversion@ } -@compatversion@ -@compatversion@ if [ "$MODULES_USE_COMPAT_VERSION" != '1' ]; then # setup FPATH to put module completion at hand in case zsh completion enabled if [[ ! ":$FPATH:" =~ ':@initdir@/zsh-functions:' ]]; then FPATH=@initdir@/zsh-functions${FPATH:+:}$FPATH export FPATH fi -@compatversion@ # no completion support on compat version -@compatversion@ elif typeset -f compdef >/dev/null; then -@compatversion@ compdef -d module -@compatversion@ fi @setbinpath@ @setbinpath@ if [[ ! ":$PATH:" =~ ':@bindir@:' ]]; then @setbinpath@@prependbinpath@ PATH=@bindir@${PATH:+:}$PATH