In my case, the pattern is expanded to:
if [[ ! ":$PATH:" =~ ':${MODULES_ROOT}/modules-tcl/bin:' ]]; then
PATH=${MODULES_ROOT}/modules-tcl/bin${PATH:+:}$PATH; export PATH
fi
And the single quote around the right-hand-side operand of the =~ operator explains why the condition does not work in my case.
So my only question is with regards to the quoting of the right-hand-side operand. According to the git log, it has always been with single quotes. when I change it to double quotes, it runs as intended (and the PATH does not grow). This is an installation I inherited.
Should it be double-quotes instead of single-quote?
What do you think?
Martin
________________________________
From: Xavier Delaruelle <xav...@gm...>
Sent: Wednesday, June 1, 2022 1:41 PM
To: Environment Modules usage and discussion. <mod...@li...>
Subject: [**EXTERNAL**] Re: [Modules] PATH grows by @bindir@ every time modules is initialized
Hi Martin,
When installing Modules the @bindir@ pattern is replaced by the configured location for Modules utilities. In the bash initialization script produced (init/bash generated from init/bash.in [bash.in]<https://urldefense.com/v3/__http://bash.in__;!!OSsGDw!OvzT2vTXisLJ436Wx1FPwnuBOMHznXuPozQ-POhdMnjwQL_BDh7AeJ7zrdMlrnn404RHCUrwqpMRP2d8W71SQG0p$>) this bin location is then added to the PATH.
The code you spot is made to avoid adding this bin location if it is already defined in the PATH.
Could you please describe how Modules is built and installed on your side and how it is initialized and what value of PATH you obtain after this initialization.
Regards,
Xavier
Le mer. 1 juin 2022 à 16:58, Martin d'Anjou <mar...@gm...<mailto:mar...@gm...>> a écrit :
Hi,
My PATH keeps growing with the same value of @bindir@ over and over when modules is repeatedly initialized, and I suspect that the code below is the reason. So inside modules-tcl/init/bash.in [bash.in]<https://urldefense.com/v3/__http://bash.in__;!!OSsGDw!OvzT2vTXisLJ436Wx1FPwnuBOMHznXuPozQ-POhdMnjwQL_BDh7AeJ7zrdMlrnn404RHCUrwqpMRP2d8W71SQG0p$>, I would like to know the purpose of this code [github.com]<https://urldefense.com/v3/__https://github.com/cea-hpc/modules/blob/c1fd4dc12f591bb877f392d7307151640573d443/init/bash.in*L68-L72__;Iw!!OSsGDw!OvzT2vTXisLJ436Wx1FPwnuBOMHznXuPozQ-POhdMnjwQL_BDh7AeJ7zrdMlrnn404RHCUrwqpMRP2d8W-xC0w3j$>:
@setbinpath@ if [[ ! ":$PATH:" =~ ':@bindir@:' ]]; then
@setbinpath@@prependbinpath@ PATH=@bindir@${PATH:+:}$PATH
@setbinpath@@appendbinpath@ PATH=$PATH${PATH:+:}@bindir@
@setbinpath@ export PATH
@setbinpath@ fi
Thanks,
Martin
_______________________________________________
Modules-interest mailing list
Mod...@li...<mailto:Mod...@li...>
https://lists.sourceforge.net/lists/listinfo/modules-interest [lists.sourceforge.net]<https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/modules-interest__;!!OSsGDw!OvzT2vTXisLJ436Wx1FPwnuBOMHznXuPozQ-POhdMnjwQL_BDh7AeJ7zrdMlrnn404RHCUrwqpMRP2d8W2H7zimz$>
|