Changeset 22


Ignore:
Timestamp:
09/21/07 14:53:17 (17 years ago)
Author:
pinsard
Message:

bug fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bibopa.sh

    r21 r22  
    55#    Dipole on the East African Short Rains: A CGCM Study, J. Climate, In 
    66#    press. 
    7 #     
     7# 
    88#    donnerait 
    9 #     
     9# 
    1010#    <biblioentry id="behara2004"> 
    1111#    <authorgroup> 
     
    2525#    <biblioid class="doi">doi</bibliomisc> 
    2626#    <bibliomisc role="pseudoref">In press.</bibliomisc> 
    27 #    <bibliomisc role="internalref">from  
     27#    <bibliomisc role="internalref">from 
    2828#    http://www.lodyc.jussieu.fr/~opatlod/NEMO_v1/6_Menu/2_page/index.html 
    2929#    2007-03-29T16:24:31Z fplod by hand</bibliomisc> 
    3030#    </biblioentry> 
    31 #     
     31# 
    3232# 
    3333# example : 
     
    4141# 
    4242# update 
    43 # ++ gestion des comments  
     43# ++ gestion des comments 
    4444# ++ gestion des id existants (cf à la fin) 
    4545# ++ option debug 
     
    5454# comments  (line begininig with #) are now possible 
    5555# Sebastien Masson avril 2007 creation 
    56 #  
     56# 
    5757 
    5858rmbl () { 
    59     echo "$1" | sed -e "s/^ *//" | sed -e "s/ *$//" 
     59    echo "${1}" | sed -e "s/^ *//" | sed -e "s/ *$//" 
    6060} 
    6161cleanname () { 
    62     echo "$1" | sed -e "s/^ *//" \ 
     62    echo "${1}" | sed -e "s/^ *//" \ 
    6363        -e "s/^ *,//" \ 
    6464        -e "s/^ *;//" \ 
     
    8686usage=" Usage : ${command} -i filein -t type" 
    8787# 
    88 while [ ! -z "${1}" ] # ++ pb bash 
     88minargcount=4 
     89echo " narg ${#}" 
     90if [ ${#} -lt ${minargcount} ] 
     91then 
     92  echo "eee : not enought arguments" 
     93  echo "${usage}" 
     94  exit 1 
     95fi 
     96# 
     97while [ ! -z "${1}" ] 
    8998do 
    9099 case ${1} in 
    91  -i) # filein  
     100 -i) # filein 
    92101  filein=${2} 
    93102  shift 
    94103 ;; 
    95  -t) # type  
     104 -t) # type 
    96105  type=${2} 
    97106  shift 
     107 ;; 
     108 -h) 
     109  echo "${usage}" 
     110  exit 0 
    98111 ;; 
    99112 *) # other choice 
     
    104117 shift # next flag 
    105118done 
    106 #  
     119# 
    107120set -u 
    108121# 
    109 # check for filein  
     122# check for filein 
    110123if [ ! -f ${filein} ] 
    111124then 
     
    130143 #read a #++ if debug 
    131144;; 
    132 *)  
     145*) 
    133146   echo "eee : type should be raw or mailbody" 
    134147   exit 1 
     
    242255do 
    243256# extract one line 
    244  
    245257  line=$( sed -n ${l}p ${fileraw_strict} ) 
    246258  orgline=$( echo ${line} | sed -e "s/--/- -/g" ) 
     
    267279  num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" ${fileou} ) 
    268280  num=$(( ${num} + 1 )) 
    269   [ ${num} -le 9 ] && num=0${num}  
     281  [ ${num} -le 9 ] && num=0${num} 
    270282  refid=${refid}_${num} 
    271    
     283 
    272284          cat <<EOF >> ${fileou} 
    273285<biblioentry id="${refid}"> 
     
    276288  --> 
    277289  <!-- original text 
    278   $orgline 
     290  ${orgline} 
    279291  --> 
    280292  <authorgroup> 
    281293    <author> <personname> <surname>${firstsn}</surname> <firstname>${firstfn}</firstname> </personname> </author> 
    282294EOF 
    283    
     295 
    284296## other authors.. 
    285297  previous=${first}, 
     
    299311# 
    300312    echo "    <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou} 
     313    echo "    <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>"  #++debug 
    301314    previous=${next}, 
    302315    next=${auths##*${previous}} 
    303      
     316 
    304317  done 
    305318  echo "  </authorgroup>"  >> ${fileou} 
    306    
     319 
    307320# end of the line ; after the first : 
    308321  endline=${line#*:} 
    309    
     322 
    310323## find the journal 
    311324  j=1 
    312325  jfound="" 
    313326  jlistsize=${#jlist[@]} 
    314   while [[ $j -le $jlistsize && "${jfound}" == "" ]] 
     327  while [[ ${j} -le ${jlistsize} && "${jfound}" == "" ]] 
    315328    do 
    316     ok=$( echo ${endline} | grep -ci "${jlist[j]} *," )  
     329    ok=$( echo ${endline} | grep -ci "${jlist[j]} *," ) 
    317330    [ $ok -eq 1 ] && jfound="${jlist[j]}" 
    318     j=$(( $j + 1 )) 
     331    j=$(( ${j} + 1 )) 
    319332  done 
    320   if [ "$jfound" == "" ] 
     333  if [ "${jfound}" == "" ] 
    321334      then 
    322       echo "ERROR Journal not found" 
     335      echo "eee: Journal not found " 
    323336      echo "${endline}" 
    324337      exit 
    325338  fi 
    326 ## title  
     339## title 
    327340# before the first : 
    328341  title=${endline%%${jfound}*} 
    329342  title=$( cleanname "${title}" ) 
    330343  echo "  <title>${title}</title>" >> ${fileou} 
    331 ## end  
     344## end 
    332345## end of the line ; after the first ${jfound} 
    333346  endline=${endline#*${jfound}} 
     
    336349  endline=$( echo ${endline} | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" ) 
    337350  ok=$( echo ${endline} | grep -ic "doi:" ) 
    338   if [ $ok -eq 1 ] 
     351  if [ ${ok} -eq 1 ] 
    339352      then 
    340353      doi=${endline##*doi:} 
     
    347360  num=$( echo ${endline} |  tr -dc "," | wc -c ) 
    348361  case ${num} in 
    349       1)  
     362      1) 
    350363### echo ${num}: ${endline} 
    351364          vol=${endline%,*} 
    352365          vol=$( cleanname "${vol}" ) 
    353           pag=${endline##*,}  
     366          pag=${endline##*,} 
    354367          pag=$( cleanname "${pag}" ) 
    355368          cat <<EOF >> ${fileou} 
     
    361374EOF 
    362375      ;; 
    363       2)  
     376      2) 
    364377          vol=${endline%,*} 
    365378          vol=$( cleanname "${vol}" ) 
    366           iss=${vol##*,}  
     379          iss=${vol##*,} 
    367380          iss=$( cleanname "${iss}" ) 
    368381          vol=${vol%,*} 
    369382          vol=$( cleanname "${vol}" ) 
    370           pag=${endline##*,}  
     383          pag=${endline##*,} 
    371384          pag=$( cleanname "${pag}" ) 
    372385          cat <<EOF >> ${fileou} 
     
    389402      ;; 
    390403  esac 
    391   
     404 
    392405          cat <<EOF >> ${fileou} 
    393406</biblioentry> 
    394    
    395 EOF 
    396  
    397  
    398  
    399  
    400    
    401   l=$(( $l + 1 )) 
    402    
     407 
     408EOF 
     409 
     410 
     411 
     412 
     413 
     414  l=$(( ${l} + 1 )) 
     415 
    403416done 
    404417echo "</bibliography>" >> ${fileou} 
     
    413426# clean 
    414427echo "iii : xml.err contains stderr from the following command " 
    415 echo "iii : which was done just to check consistence of ${fileou}"  
     428echo "iii : which was done just to check consistence of ${fileou}" 
    416429echo "iii : xmlto pdf ${fileou}" 
    417430rm -i xml.err 
    418431case ${type} in 
    419 raw)  
     432raw) 
    420433 echo "iii : ${fileraw_strict} contains a copy of input file without comments" 
    421434 rm -i ${fileraw_strict} 
Note: See TracChangeset for help on using the changeset viewer.