Thanks a lot for these coding suggestions.
frank
On 08/03/2017 08:59 PM, Paul FM wrote:
> As for your tcl code,
>
> You might want use locale variables and set sane values before parsing
> and then enclose your code to read $env into those variables, in a catch
> block. Like this:
>
> set os_distro "unknown"
> set ... "unknown"
> set ... "unknown"
> catch {
> set os_distro $env(DISTRO)
> set ...
> set ...
> }
>
> switch "${os_distro}" {
> ...
> }
>
>
> That way, if for some reason DISTRO isn't set, your module file won't
> crash.
>
> Note: I tend to quote and escape my environment variables for good measure.
>
>
>
> On 8/3/2017 1:39 PM, Sternberg, Michael G. wrote:
>> Frank,
>>
>> Distro-detection and distro-specific code inside individual
>> modulefiles would be repetitive and fragile, and would quickly become
>> difficult to maintain. For a multi-distro system here, I use several
>> modulefile trees, presenting distro-specific trees before shared ones:
>>
>> $ echo $MODULEPATH
>> /opt/apps/M/el6:/opt/apps/M/el:/usr/share/Modules/modulefiles:/etc/modulefiles
>>
>>
>>
>> To add to what Paul just wrote, lsb_release(1) is provided on CentOS
>> by package redhat-lsb-core. As part of scripts in /etc/profile.d/, I use:
>>
>> $ lsb_release -sir
>> CentOS 6.9
>>
>> Has a nice ring to it and is easy to parse.
>>
>>
>> With best regards,
>> Michael
>>
>>
>>> On 2017-08-03, at 12:53 , Frank Thommen
>>> <f.t...@dk...> wrote:
>>> I am currently trying to generalize our modulefiles so that the same
>>> file can be used for different Linux distros. For historical
>>> reasons, openSuSE and CentOS hosts @work have different base paths of
>>> their respective software stack.
>>>
>>> Therefore my question: Is there a simple Tcl command that allows me
>>> to detect the current Linux distribution or how could I detect it
>>> otherwise? I can do it with bash, but I have no knowledge of Tcl
>>> other than our very basic and simple modulefiles.
>>>
>>> Any hint is appreciated.
>>>
>>> Cheers
>>> frank
>>
>>
>> ------------------------------------------------------------------------------
>>
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Modules-interest mailing list
>> Mod...@li...
>> https://lists.sourceforge.net/lists/listinfo/modules-interest
>>
>
--
Frank Thommen | DKFZ Heidelberg / B080
| System Administrator
| f.t...@dk...
| MMK: +49-6221-42-3637 (Mo-Mi, Fr)
| IPMB: +49-6221-54-5823 (Do)
|