Changeset 24085


Ignore:
Timestamp:
07/11/19 19:28:09 (6 years ago)
Author:
jdquinn
Message:

CHG: Modified *append/*prepend functions to deal with case where environment variable is empty.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/etc/environment.sh

    r23763 r24085  
    1 #ISSM_DIR and ISSM_ARCH should have been defined already in your shell settings file (.bashrc, .cshrc, etc ...)
    2 
     1# Modifies path-related envrionment variables based on which external packages
     2# have been installed.
     3#
     4# ISSM_DIR and ISSM_ARCH should have been defined already in your shell
     5# settings file (i.e. .bashrc, .cshrc).
     6
     7## Functions
     8#
    39pathprepend(){ #{{{
    410        if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
     
    2228} #}}}
    2329libpathprepend(){ #{{{
    24         if [ -d "$1" ] && [[ ":$LD_LIBRARY_PATH:" != *":$1:"* ]]; then
    25                 export LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH"
    26         fi
    27         if [ -d "$1" ] && [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
    28                 export LD_RUN_PATH="$1:$LD_RUN_PATH"
     30        if [ -d "$1" ]; then
     31                if [ -z $LD_LIBRARY_PATH ]; then
     32                        export LD_LIBRARY_PATH="$1"
     33                elif [[ ":$LD_LIBRARY_PATH:" != *":$1:"* ]]; then
     34                        export LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH"
     35                fi
     36                if [ -z $LD_RUN_PATH ]; then
     37                        export LD_RUN_PATH="$1"
     38                elif [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
     39                        export LD_RUN_PATH="$1:$LD_RUN_PATH"
     40                fi
    2941        fi
    3042} #}}}
    3143libpathappend(){ #{{{
    32         if [ -d "$1" ] && [[ ":$LD_LIBRARY_PATH:" != *":$1:"* ]]; then
    33                 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$1"
    34         fi
    35         if [ -d "$1" ] && [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
    36                 export LD_RUN_PATH="$LD_RUN_PATH:$1"
     44        if [ -d "$1" ]; then
     45                if [ -z $LD_LIBRARY_PATH ]; then
     46                        export LD_LIBRARY_PATH=$1
     47                elif [[ ":$LD_LIBRARY_PATH:" != *":$1:"* ]]; then
     48                        export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$1"
     49                fi
     50                if [ -z $LD_RUN_PATH ]; then
     51                        export LD_RUN_PATH=$1
     52                elif [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
     53                        export LD_RUN_PATH="$LD_RUN_PATH:$1"
     54                fi
    3755        fi
    3856} #}}}
    3957dylibpathprepend(){ #{{{
    40         if [ -d "$1" ] && [[ ":$DYLD_LIBRARY_PATH:" != *":$1:"* ]]; then
    41                 export DYLD_LIBRARY_PATH="$1:$DYLD_LIBRARY_PATH"
    42         fi
    43         if [ -d "$1" ] && [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
    44                 export LD_RUN_PATH="$1:$LD_RUN_PATH"
     58        if [ -d "$1" ]; then
     59                if [ -z $DYLD_LIBRARY_PATH ]; then
     60                        export DYLD_LIBRARY_PATH=$1
     61                elif [[ ":$DYLD_LIBRARY_PATH:" != *":$1:"* ]]; then
     62                        export DYLD_LIBRARY_PATH="$1:$DYLD_LIBRARY_PATH"
     63                fi
     64                if [ -z $LD_RUN_PATH ]; then
     65                        export LD_RUN_PATH=$1
     66                elif [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
     67                        export LD_RUN_PATH="$1:$LD_RUN_PATH"
     68                fi
    4569        fi
    4670} #}}}
    4771dylibpathappend(){ #{{{
    48         if [ -d "$1" ] && [[ ":$DYLD_LIBRARY_PATH:" != *":$1:"* ]]; then
    49                 export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$1"
    50         fi
    51         if [ -d "$1" ] && [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
    52                 export LD_RUN_PATH="$LD_RUN_PATH:$1"
    53         fi
    54 } #}}}
    55 
    56 #FIXME: during installation packages are installed one by one but environment.sh was sourced
    57 #before so new packages are NOT in the path.
    58 #may resource environment.sh with:
    59 #if [ -z $(echo "$PATH" | grep "$MATLAB_DIR") ]; then export $PATH...; fi
    60 
    61 #Windows compilers:
     72        if [ -d "$1" ]; then
     73                if [ -z $DYLD_LIBRARY_PATH ]; then
     74                        export DYLD_LIBRARY_PATH=$1
     75                elif [[ ":$DYLD_LIBRARY_PATH:" != *":$1:"* ]]; then
     76                        export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$1"
     77                fi
     78                if [ -z $LD_RUN_PATH ]; then
     79                        export LD_RUN_PATH=$1
     80                elif [[ ":$LD_RUN_PATH:" != *":$1:"* ]]; then
     81                        export LD_RUN_PATH="$LD_RUN_PATH:$1"
     82                fi
     83        fi
     84} #}}}
     85
     86# FIXME: during installation packages are installed one by one but
     87# environment.sh was sourced before so new packages are NOT in the path. May
     88# source environment.sh again with:
     89#       if [ -z $(echo "$PATH" | grep "$MATLAB_DIR") ]; then export $PATH...; fi
     90
     91# Windows compilers:
    6292if [[ "$ISSM_ARCH" == "cygwin-intel" ]]; then
    6393        source $ISSM_DIR/externalpackages/windows/windows_environment.sh
    6494fi
    6595
    66 #Load ISSM scripts
     96# Load ISSM scripts
    6797pathappend "$ISSM_DIR/scripts"
    6898
    69 #GMT
    7099GMT_DIR="$ISSM_DIR/externalpackages/gmt/install"
    71100if [ -d "$GMT_DIR" ]; then
Note: See TracChangeset for help on using the changeset viewer.