Skip to content

How to source a csh script into a modulefile? #399

@rdauria

Description

@rdauria

Hello,

Sorry for posting here, but I am not sure whether this is a question or a feature request. I have been using the sourcing of scripts to create environmental modules as described here:

https://modules.readthedocs.io/en/latest/cookbook/source-script-in-modulefile.html

in particular:

#%Module4.6
source-sh bash example/source-script-in-modulefile/foo-1.2/foo-setup.sh arg1
EOF

Is there a way to source csh/tcsh scripts? I could not find mention in the documentation (https://modules.readthedocs.io/en/latest/cookbook/source-script-in-modulefile.html) or a man page that would describe the syntax. Should one use something line:

#%Module4.6
source-sh csh example/source-script-in-modulefile/foo-1.2/foo-setup.csh arg1
EOF

Notice that the use case is to create a modulefile for anaconda that will prevent the users from running:

conda init

which (quite ignorantly - I should say) writes in the user initialization files. The idea is to use instead in the modulefile for anaconda something along the lines of:

set myshell $::env(SHELL)

if {  $myshell == "/bin/bash" || $myshell == "/bin/dash" || $myshell == "/bin/ksh" || $myshell == "/bin/sh"  || $myshell == "/bin/zsh" } then {
        source-sh bash /path/to/anaconda3/etc/profile.d/conda.sh
} elseif {  $myshell == "/bin/csh" || $myshell == "/bin/tcsh" } then {
        source-sh csh /path/to/anaconda3/etc/profile.d/conda.csh
}

which would support both sh-based as well as csh-based shells.

The problem is that:

source-sh csh /path/to/anaconda3/etc/profile.d/conda.csh

does not appear to work.

Do you have any suggestions? If csh script can be sources could you update the documentation an upload and example?

Thanks,

RD

Please use preferably the Modules mailing-list to post question:

https://sourceforge.net/projects/modules/lists/modules-interest

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions