File: bash.in

package info (click to toggle)
lmod 8.7.60-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,008 kB
  • sloc: sh: 6,266; makefile: 2,837; ansic: 1,513; tcl: 1,382; python: 1,050; csh: 112
file content (188 lines) | stat: -rw-r--r-- 5,613 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
# -*- shell-script -*-
#
########################################################################
# Start Lmod BASHENV
########################################################################

if [ -z "${LMOD_SH_DBG_ON+x}" ]; then
   case "$-" in
     *v*x*) __lmod_vx='vx' ;;
     *v*)   __lmod_vx='v'  ;;
     *x*)   __lmod_vx='x'  ;;
   esac;
fi

[ -n "${__lmod_vx:-}" ] && set +$__lmod_vx 

if [ -n "${__lmod_vx:-}" ]; then
    echo "Shell debugging temporarily silenced: export LMOD_SH_DBG_ON=1 for this output (@PKGV@/init/@my_shell@)" 1>&2
fi

unset __zsh_fpath
if [ -n "${ZSH_VERSION+x}" ] &&  ! (autoload -U compinit && compinit -C 2> /dev/null) ; then
  __zsh_fpath=$(unset FPATH; zsh -f -c 'echo $FPATH')
fi
export FPATH=$(@PKGV@/libexec/addto --append FPATH ${__zsh_fpath:-$FPATH} @PKGV@/init/ksh_funcs)
unset __zsh_fpath

export LMOD_ROOT=@lmod_root@
export LMOD_PKG=@PKGV@
export LMOD_DIR=$LMOD_PKG/libexec
export LMOD_CMD=$LMOD_PKG/libexec/lmod
export MODULESHOME=$LMOD_PKG
export LMOD_SETTARG_FULL_SUPPORT=@lmod_settarg_full_support@

########################################################################
#  Define the module command:  The first line runs the "lmod" command
#  to generate text:
#      export PATH="..."
#  then the "eval" converts the text into changes in the current shell.
#
#  The second command is the settarg command.  Normally LMOD_SETTARG_CMD
#  is undefined or is ":".  Either way the eval does nothing.  When the
#  settarg module is loaded, it defines LMOD_SETTARG_CMD.  The settarg
#  command knows how to read the ModuleTable that Lmod maintains and
#  generates a series of env. vars that describe the current state of
#  loaded modules.  So if one is on a x86_64 linux computer with gcc/4.7.2
#  and openmpi/1.6.3 loaded, then settarg will assign:
#
#     TARG=_x86_64_gcc-4.7.2_openmpi-1.6.3
#     TARG_COMPILER=gcc-4.7.2
#     TARG_COMPILER_FAMILY=gcc
#     TARG_MACH=x86_64
#     TARG_MPI=openmpi-1.6.3
#     TARG_MPI_FAMILY=openmpi
#     TARG_SUMMARY=x86_64_gcc-4.7.2_openmpi-1.6.3
#     TARG_TITLE_BAR=gcc-4.7.2 O-1.6.3
#     TARG_TITLE_BAR_PAREN=(gcc-4.7.2 O-1.6.3)
#
#  unloading openmpi/1.6.3 automatically changes these vars to be:
#
#     TARG=_x86_64_gcc-4.6.3
#     TARG_COMPILER=gcc-4.6.3
#     TARG_COMPILER_FAMILY=gcc
#     TARG_MACH=x86_64
#     TARG_SUMMARY=x86_64_gcc-4.6.3
#     TARG_TITLE_BAR=gcc-4.6.3
#     TARG_TITLE_BAR_PAREN=(gcc-4.6.3)
#
# See Lmod web site for more details.


if [ "@silence_shell_debugging@" = "no" ]; then
   module()
   {
     ############################################################
     # Run Lmod and eval results
     eval "$($LMOD_CMD @my_shell@ "$@")" && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
   }
else
   module()
   {
     ############################################################
     # Silence shell debug UNLESS $LMOD_SH_DBG_ON has a value
     if [ -z "${LMOD_SH_DBG_ON+x}" ]; then
        case "$-" in
          *v*x*) __lmod_sh_dbg='vx' ;;
          *v*)   __lmod_sh_dbg='v'  ;;
          *x*)   __lmod_sh_dbg='x'  ;;
        esac;
     fi
     
     if [ -n "${__lmod_sh_dbg:-}" ]; then
        set +$__lmod_sh_dbg 
        echo "Shell debugging temporarily silenced: export LMOD_SH_DBG_ON=1 for Lmod's output" 1>&2
     fi

     ############################################################
     # Run Lmod and eval results
     eval "$($LMOD_CMD shell "$@")" && eval "$(${LMOD_SETTARG_CMD:-:} -s sh)"
     __lmod_my_status=$?

     ############################################################
     # Un-silence shell debug after module command
     if [ -n "${__lmod_sh_dbg:-}" ]; then
       echo "Shell debugging restarted" 1>&2
       set -$__lmod_sh_dbg;
     fi;
     unset __lmod_sh_dbg
     return $__lmod_my_status
   }
fi


LMOD_VERSION="@lmod_version@"
export LMOD_VERSION

if [ "${LMOD_SETTARG_CMD:-:}" != ":" ]; then
  settarg () {
    eval $(${LMOD_SETTARG_CMD:-:} -s sh "$@" )
  }
fi


########################################################################
#  ml is a shorthand tool for people who can't type moduel, err, module
#  It is also a combination command:
#     ml            -> module list
#     ml gcc        -> module load gcc
#     ml -gcc intel -> module unload gcc; module load intel
#  It does much more. Do: "ml --help" for more information.


unalias ml 2> /dev/null || true
ml()
{
  eval "$($LMOD_DIR/ml_cmd "$@")"
}

if [ -n "${BASH_VERSION:-}" -a "@export_module@" != no ]; then
  export -f module
  export -f ml
fi
unset export_module

########################################################################
#  clearMT removes the ModuleTable from your environment.  It is rarely
#  needed but it useful sometimes.

clearMT()
{
  eval $($LMOD_DIR/clearLMOD_cmd --shell bash --simple)
}

clearLmod()
{
  module --force purge
  eval $($LMOD_DIR/clearLMOD_cmd --shell bash --full "$@")
}

xSetTitleLmod()
{
  builtin echo -n -e "\033]2;$1\007";
}

########################################################################
#  Make tab completions available to bash users.

if [ ${BASH_VERSINFO:-0} -ge 3 ] && [ -r  @PKGV@/init/lmod_bash_completions ] && [ -n "${PS1:-}" ] && [ -z "${POSIXLY_CORRECT:-}" ]; then
 . @PKGV@/init/lmod_bash_completions
fi


# Restoring XTRACE and VERBOSE states.
if [ -n "${__lmod_vx:-}" ]; then
  echo "Shell debugging restarted" 1>&2
  set -$__lmod_vx;
  unset __lmod_vx;
fi;

########################################################################
# End Lmod BASHENV
########################################################################
#
# Local Variables:
# mode: shell-script
# indent-tabs-mode: nil
# End: