Skip to content

execute a bash script within the modulesfile #346

@amamory

Description

@amamory

Is your feature request related to a problem? Please describe.

There tools that already have their own setup script, to set their environment variables.
However, they lack the ability to unload them, as 'module' does.

Describe the solution you'd like

Module1.0#####################################################################
##
## modules Xilinx
##
# Local variables
set MODULE "xilinx"
set VERSION "2019.2"
set BASE "/home/lsa/xilinx/Xilinx"

# License 
setenv XILDIR /home/lsa/xilinx/Xilinx

# Helps
module-whatis "Xilinx and Petalinux environment"
# unfortunately, it is not possible to pass the environment variables to the calling term :(
#exec bash /home/lsa/xilinx/Xilinx/Vitis/2019.2/settings64.sh
#exec bash /home/lsa/xilinx/Xilinx/petalinux/settings.sh

#if { [catch { exec /bin/bash -c "source /home/lsa/xilinx/Xilinx/Vitis/2019.2/settings64.sh" } msg] } {
#   puts "ERROR runnig source /home/lsa/xilinx/Xilinx/Vitis/2019.2/settings64.sh"
#   puts "Information about it: $::errorInfo"
#}
#if { [catch { exec /bin/bash -c "source /home/lsa/xilinx/Xilinx/petalinux/settings.sh" } msg] } {
#   puts "ERROR runnig source /home/lsa/xilinx/Xilinx/petalinux/settings.sh"
#   puts "Information about it: $::errorInfo"
#}

# Simple user information
if { [ module-info mode load ] } {
        puts stderr "\n\ttype: source /home/lsa/xilinx/Xilinx/Vitis/2019.2/settings64.sh"
        puts stderr "\n\ttype: source /home/lsa/xilinx/Xilinx/petalinux/settings.sh"
}

if { [ module-info mode remove ] } {
        puts stderr "\n\topen a new terminal to revome the definitions\n"
}

The commented lines execute, but the environment variables are not set within 'modules'.
However, if I run the same script directly in the bash terminal, it works. The variables are created.

Describe alternatives you've considered

These bash scripts are usually complex. They dont only set few env vars. So translating them to TCL is not an option.

Any idea to make this work ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions