If I use a puts command to set the variable, is there a way to have the module unset that value when I run module unload?
Byron Boulton
On Tue, Dec 3, 2024 at 2:59 PM, Xavier Delaruelle <[xav...@gm...](mailto:On Tue, Dec 3, 2024 at 2:59 PM, Xavier Delaruelle <<a href=)> wrote:
> Hello Byron,
>
> Setting a multi-line value to an environment variable with "setenv" is
> not possible with current version of Modules. I will look at
> implementing such feature.
>
> As a workaround, you may use the "puts" command to craft the shell
> command to define variable with such specific value:
>
> #%Module
> puts stdout "export FOO='my\nmulti\nline\nvalue';"
>
> Regards,
> Xavier
>
> Le mar. 3 déc. 2024 à 15:16, Byron Boulton via Modules-interest
> <mod...@li...> a écrit :
>>
>> I need to set-env a variable with contents from a file. In bash I can do this with
>>
>> export FOO="$(cat /home/username/foofile.dat)"
>>
>> So far I tried various permutations like
>>
>> set fp [open "/home/username/foofile.dat"]
>> set file_data [read $fp]
>> close $fp
>> set-env FOO "$file_data"
>>
>> But I always end up with a “command not found” message from bash trying to evaluate the second line of the file. This shows me that the module load must outputting a string to bash that is only setting the first line of the file to the variable FOO, then the subsequent file lines are getting dropped right to bash to evaluate.
>>
>> Does anyone have ideas on how I can set a multiline variable from the contents of a file?
>>
>> (Some keywords for future searchability in the archives: multiline, multi-line, newline)
>>
>> Byron
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest |