Changeset 48 for trunk/geomag_profile.sh


Ignore:
Timestamp:
03/16/14 20:38:39 (10 years ago)
Author:
pinsard
Message:

fix thanks to coding rules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/geomag_profile.sh

    r47 r48  
    3030# =========== 
    3131# 
    32 # .. option:: -d  <directory> 
    33 # .. option:: -i  <indir> 
    34 # .. option:: -o  <outdir> 
    35 # .. option:: -t  <tempdir> 
     32# .. option:: -d <directory> 
     33# .. option:: -i <indir> 
     34# .. option:: -o <outdir> 
     35# .. option:: -t <tempdir> 
    3636# 
    3737# define GEOMAG environment 
     
    7373# ++ besoin de posix 
    7474# 
    75 # ++ pas de MANPATH defini par défaut sur zeus 
     75# ++ pas de MANPATH defini par défaut sur zeus 
    7676# 
    7777# EVOLUTIONS 
     
    116116usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" 
    117117# 
    118 set +u 
    119 while [ ! -z "${1}" ] 
    120 do 
    121    case ${1} in 
    122       -d) 
    123          # directory for application choosen by user (see svn checkout command used) 
    124          directory=${2} 
    125          shift 
    126       ;; 
    127       -i) 
    128          # directory for inputs choosen by user 
    129          indir=${2} 
    130          shift 
    131       ;; 
    132       -o) 
    133          # directory for outputs choosen by user 
    134          outdir=${2} 
    135          shift 
    136       ;; 
    137       -t) 
    138          # directory for temporary outputs choosen by user 
    139          tempdir=${2} 
    140          shift 
    141       ;; 
    142       *) 
    143          # other choice 
    144          echo "eee : unknown option ${1}" 
    145          echo "${usage}" 
    146          # nb : no exit because this file should be launched by login process 
    147       ;; 
    148    esac 
    149    # next flag 
    150    shift 
    151 done 
    152 unset usage 
    153 # 
    154118set -u 
    155 # 
    156 # check for ${directory} 
    157 if [ ! -d ${directory} ] 
     119pb=0 
     120# 
     121minargcount=8 
     122maxargcount=8 
     123narg=${#} 
     124# 
     125if [ ${narg} -lt ${minargcount} ] 
    158126then 
    159    echo " eee : ${directory} not found" 
    160    # nb : no exit because this file should be launched by login process 
     127    echo "eee : not enought arguments (${narg} vs ${minargcount})" 
     128    echo "${usage}" 
     129    # nb : no exit because this file should be launched by login process 
     130    pb=1 
    161131fi 
    162 # 
    163 # check for permission on directory 
    164 if [ ! -x ${directory} ] 
     132unset minargcount 
     133# 
     134if [ ${narg} -gt ${maxargcount} ] 
    165135then 
    166    echo " eee : ${directory} not reachable" 
    167    # nb : no exit because this file should be launched by login process 
     136    echo "eee : too many arguments (${narg} vs ${maxargcount})" 
     137    echo "${usage}" 
     138    # nb : no exit because this file should be launched by login process 
     139    pb=1 
    168140fi 
    169 # 
    170 set -u 
    171 system=$(uname) 
    172 case "${system}" in 
    173    IRIX64) 
    174       echo " www : no specific posix checking" 
    175    ;; 
    176    *) 
    177       set -o posix 
    178    ;; 
    179 esac 
    180 unset system 
    181 # 
    182 GEOMAG=${directory} 
    183 export GEOMAG 
    184 unset directory 
    185 # 
    186 # add GEOMAG tools to PATH 
    187 # if not already done 
    188 suppath=$(echo ${GEOMAG} | tr -s "/") 
    189 echo ${PATH} | grep -q "${suppath}:" 
    190 test_path=${?} 
    191 if [ ${test_path} -ne 0 ] 
     141unset maxargcount 
     142unset narg 
     143# 
     144if [ ${pb} -eq 0 ] 
    192145then 
    193    PATH=${suppath}:${PATH} 
    194    export PATH 
    195 else 
    196    # option bavarde oui/non pas encore implantée ++ 
    197    echo "${command} : iii : ${suppath}/ already in \${PATH}" 
     146    # 
     147    while [ ${#} -gt 0 ] 
     148    do 
     149       case ${1} in 
     150          -d) 
     151             # directory for application choosen by user  
     152             # (see svn checkout command used) 
     153             directory=${2} 
     154             shift 
     155          ;; 
     156          -i) 
     157             # directory for inputs choosen by user 
     158             indir=${2} 
     159             shift 
     160          ;; 
     161          -o) 
     162             # directory for outputs choosen by user 
     163             outdir=${2} 
     164             shift 
     165          ;; 
     166          -t) 
     167             # directory for temporary outputs choosen by user 
     168             tempdir=${2} 
     169             shift 
     170          ;; 
     171          *) 
     172             # other choice 
     173             echo "eee : unknown option ${1}" 
     174             echo "${usage}" 
     175             # nb : no exit because this file should be launched by login process 
     176          ;; 
     177       esac 
     178       # next flag 
     179       shift 
     180    done 
     181    unset usage 
    198182fi 
    199 unset test_path 
    200 unset suppath 
    201 # 
    202 # add GEOMAG manuals to MANPATH 
    203 # if not already done 
    204 suppath=$(echo ${GEOMAG}/doc/manuals/man/ | tr -s "/") 
    205 echo ${MANPATH} | grep -q "${suppath}:" 
    206 test_manpath=${?} 
    207 if [ ${test_manpath} -ne 0 ] 
     183if [ ${pb} -eq 0 ] 
    208184then 
    209    MANPATH=${suppath}:${MANPATH} 
    210    export MANPATH 
    211 else 
    212    # option bavarde oui/non pas encore implantée ++ 
    213    echo "${command} : iii : ${suppath} already in \${MANPATH}" 
     185    # 
     186    # check for ${directory} 
     187    if [ ! -d ${directory} ] 
     188    then 
     189       echo " eee : ${directory} not found" 
     190       # nb : no exit because this file should be launched by login process 
     191    fi 
     192    # 
     193    # check for permission on directory 
     194    if [ ! -x ${directory} ] 
     195    then 
     196       echo " eee : ${directory} not reachable" 
     197       # nb : no exit because this file should be launched by login process 
     198    fi 
     199    # 
     200    system=$(uname) 
     201    case "${system}" in 
     202       IRIX64) 
     203          echo " www : no specific posix checking" 
     204       ;; 
     205       *) 
     206          set -o posix 
     207       ;; 
     208    esac 
     209    unset system 
     210    # 
     211    GEOMAG=${directory} 
     212    export GEOMAG 
     213    unset directory 
     214    # 
     215    # add GEOMAG tools to PATH 
     216    # if not already done 
     217    suppath=$(echo ${GEOMAG} | tr -s "/") 
     218    echo ${PATH} | grep -q "${suppath}:" 
     219    test_path=${?} 
     220    if [ ${test_path} -ne 0 ] 
     221    then 
     222       PATH=${suppath}:${PATH} 
     223       export PATH 
     224    else 
     225       # option bavarde oui/non pas encore implantée ++ 
     226       echo "${command} : iii : ${suppath}/ already in \${PATH}" 
     227    fi 
     228    unset test_path 
     229    unset suppath 
     230    # 
     231    # add GEOMAG manuals to MANPATH 
     232    # if not already done 
     233    suppath=$(echo ${GEOMAG}/doc/manuals/man/ | tr -s "/") 
     234    echo ${MANPATH} | grep -q "${suppath}:" 
     235    test_manpath=${?} 
     236    if [ ${test_manpath} -ne 0 ] 
     237    then 
     238       MANPATH=${suppath}:${MANPATH} 
     239       export MANPATH 
     240    else 
     241       # option bavarde oui/non pas encore implantée ++ 
     242       echo "${command} : iii : ${suppath} already in \${MANPATH}" 
     243    fi 
     244    unset test_manpath 
     245    unset suppath 
     246    # 
     247    GEOMAG_LOG=${tempdir} 
     248    export GEOMAG_LOG 
     249    unset tempdir 
     250    if [ ! -d ${GEOMAG_LOG} ] 
     251    then 
     252       mkdir -p ${GEOMAG_LOG} 
     253       status=${?} 
     254       if [ ${status} -ne 0 ] 
     255       then 
     256          echo "${command} : eee : can not create \${GEOMAG_LOG}" 
     257          # nb : no exit because this file should be launched by login process 
     258       else 
     259          echo "${command} : iii : creation of \${GEOMAG_LOG}" 
     260       fi 
     261       unset status 
     262    fi 
     263    # check for permission on GEOMAG_LOG 
     264    if [ ! -x ${GEOMAG_LOG} ] 
     265    then 
     266       echo " eee : ${GEOMAG_LOG} not reachable" 
     267       # nb : no exit because this file should be launched by login process 
     268    fi 
     269    # 
     270    # check for permission on GEOMAG_LOG 
     271    if [ ! -w ${GEOMAG_LOG} ] 
     272    then 
     273       echo " eee : ${GEOMAG_LOG} not writable" 
     274       # nb : no exit because this file shouldreachable be launched  
     275       # by login process 
     276    fi 
     277    # 
     278    EDITOR=vi 
     279    export EDITOR 
     280    # 
     281    # io directories 
     282    GEOMAG_ID=${indir} 
     283    export GEOMAG_ID 
     284    unset indir 
     285    if [ ! -d ${GEOMAG_ID} ] 
     286    then 
     287       mkdir -p ${GEOMAG_ID} 
     288       echo "${command} : iii : creation of \${GEOMAG_ID}" 
     289    fi 
     290    # check for permission on GEOMAG_ID 
     291    if [ ! -x ${GEOMAG_ID} ] 
     292    then 
     293       echo " eee : ${GEOMAG_ID} not reachable" 
     294       # nb : no exit because this file should be launched by login process 
     295    fi 
     296    # 
     297    GEOMAG_OD=${outdir} 
     298    export GEOMAG_OD 
     299    unset outdir 
     300    if [ ! -d ${GEOMAG_OD} ] 
     301    then 
     302       mkdir -p ${GEOMAG_OD} 
     303       echo "${command} : iii : creation of \${GEOMAG_OD}" 
     304    fi 
     305    # check for permission on GEOMAG_OD 
     306    if [ ! -x ${GEOMAG_OD} ] 
     307    then 
     308       echo " eee : ${GEOMAG_OD} not reachable" 
     309       # nb : no exit because this file should be launched by login process 
     310    fi 
     311    if [ ! -w ${GEOMAG_OD} ] 
     312    then 
     313       echo " eee : ${GEOMAG_OD} not writable" 
     314       # nb : no exit because this file should be launched by login process 
     315    fi 
     316    # 
    214317fi 
    215 unset test_manpath 
    216 unset suppath 
    217 # 
    218 GEOMAG_LOG=${tempdir} 
    219 export GEOMAG_LOG 
    220 unset tempdir 
    221 if [ ! -d ${GEOMAG_LOG} ] 
    222 then 
    223    mkdir -p ${GEOMAG_LOG} 
    224    status=${?} 
    225    if [ ${status} -ne 0 ] 
    226    then 
    227       echo "${command} : eee : can not create \${GEOMAG_LOG}" 
    228       # nb : no exit because this file should be launched by login process 
    229    else 
    230       echo "${command} : iii : creation of \${GEOMAG_LOG}" 
    231    fi 
    232    unset status 
    233 fi 
    234 # check for permission on GEOMAG_LOG 
    235 if [ ! -x ${GEOMAG_LOG} ] 
    236 then 
    237    echo " eee : ${GEOMAG_LOG} not reachable" 
    238    # nb : no exit because this file should be launched by login process 
    239 fi 
    240 # 
    241 # check for permission on GEOMAG_LOG 
    242 if [ ! -w ${GEOMAG_LOG} ] 
    243 then 
    244    echo " eee : ${GEOMAG_LOG} not writable" 
    245    # nb : no exit because this file shouldreachable be launched by login process 
    246 fi 
    247 # 
    248 EDITOR=vi 
    249 export EDITOR 
    250 # 
    251 # io directories 
    252 GEOMAG_ID=${indir} 
    253 export GEOMAG_ID 
    254 unset indir 
    255 if [ ! -d ${GEOMAG_ID} ] 
    256 then 
    257    mkdir -p ${GEOMAG_ID} 
    258    echo "${command} : iii : creation of \${GEOMAG_ID}" 
    259 fi 
    260 # check for permission on GEOMAG_ID 
    261 if [ ! -x ${GEOMAG_ID} ] 
    262 then 
    263    echo " eee : ${GEOMAG_ID} not reachable" 
    264    # nb : no exit because this file should be launched by login process 
    265 fi 
    266 # 
    267 GEOMAG_OD=${outdir} 
    268 export GEOMAG_OD 
    269 unset outdir 
    270 if [ ! -d ${GEOMAG_OD} ] 
    271 then 
    272    mkdir -p ${GEOMAG_OD} 
    273    echo "${command} : iii : creation of \${GEOMAG_OD}" 
    274 fi 
    275 # check for permission on GEOMAG_OD 
    276 if [ ! -x ${GEOMAG_OD} ] 
    277 then 
    278    echo " eee : ${GEOMAG_OD} not reachable" 
    279    # nb : no exit because this file should be launched by login process 
    280 fi 
    281 if [ ! -w ${GEOMAG_OD} ] 
    282 then 
    283    echo " eee : ${GEOMAG_OD} not writable" 
    284    # nb : no exit because this file should be launched by login process 
    285 fi 
    286 # 
     318unset pb 
    287319# end 
    288320unset command 
Note: See TracChangeset for help on using the changeset viewer.