On Thu, 10 Oct 2002 15:26:23 -0700, "Leo Butler" <lb...@br...>
said:
> Nancy E. Davis (ne...@fa...) wrote:
>
> > Hi Modules-interest,
> >
> > I am working with modules version 3.1.6 on Tru64 Unix, Tcl 8.4a1.
> > I want to evaluate a users env var and use the module file to
> > manipulate it. The env var in question is a space delimited list
> > of compiler options, i.e.,
> >
> > me@host> echo $DEC_CC
> > -L/usr/local/lib -L/var/shlib |
> >
> > When a user loads a particular module, I want to evaluate if they
> > have DEC_CC set, what it is set to, and make certain more paths
> > are included. When said user unloads a module, I want to recall
> > the previous env var and give them back what they had.
> >
> > Is this possible? I'm having trouble getting the env var out of
> > the users environment in any form. If this isn't possible, can I
> > source a script at the end of the modulefile to do this?
>
> Hello, Nancy.
>
> You can try something like this:
>
> if {([module-info mode load] || [module-info mode switch2]) && [info
> exists
> env(DEC_CC)]} {
> setenv _SAVE_DEC_CC $env(DEC_CC)
> # Now do some regexp stuff in here to process DEC_CC
> } else {
> # Remove specific items added during loading of this module
> }
Leo,
Thanks much! This works well as below:
set flags_add {
-L/usr/shlib -L/usr/ccs/lib -L/usr/lib/cmplrs/cc -L/usr/lib
-L/usr/local/lib -L/
var/shlib
}
if {([module-info mode load] || [module-info mode switch2]) && [info
exists env(DEC_
CC)]} {
setenv _SAVE_DEC_CC $env(DEC_CC)
set flags_use [concat $flags_add $env(DEC_CC)]
setenv DEC_CC $flags_use
} else {
set flags_end " | "
set flags_use [concat $flags_add $flags_end]
setenv DEC_CC $flags_use
}
For now, this is enough. Once I learn more tcl, I can think about
replacing the saved env var. I would also like to figure out how to do
some sanity checking on the list and avoid replicate entries. Some users
are coming in with no flags set, others have a very specific list that
include some or all of the flags I want them to be certain to have.
Thanks to all for your help.
Best regards,
Nancy Davis
|