Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:add more comments and fix some more quoting issues
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:dd4b854be95d1f23ac83c0f2cffafdb19a686d0b
User & Date: brandon 2016-04-06 20:37:28
Context
2016-04-06
20:41
whitespace cleanup check-in: 45c7ccd639 user: brandon tags: trunk
20:37
add more comments and fix some more quoting issues check-in: dd4b854be9 user: brandon tags: trunk
20:32
update copyright years in version output check-in: 7cc6438a09 user: brandon tags: trunk
Changes

Changes to paperq.in.

   123    123   This is free software: you are free to change and redistribute it.
   124    124   There is NO WARRANTY, to the extent permitted by law.
   125    125   EOF
   126    126       exit 0
   127    127   }
   128    128   
   129    129   add_doc () {
          130  +    # Add a document to the queue
   130    131       grep -q "$1" ${QFILE} || printf "%s\n" "$1" >>${QFILE}
   131    132       printf "%s ADDED %s\n" "$(date '+[%Y-%m-%d %H:%M]')" "$1" >>${LOGFILE}
   132    133   }
   133    134   
   134    135   get_doc () {
          136  +    # Get a document file path
   135    137       check_pos
   136    138       sed -n "${pos}p" ${QFILE}
   137    139   }
   138    140   
   139    141   rem_doc () {
          142  +    # Remove a document from the queue
   140    143       check_pos
   141    144       printf "%s REMOVED %s\n" "$(date '+[%Y-%m-%d %H:%M]')" \
   142    145              "$(sed -n "${pos}p" ${QFILE})" >>${LOGFILE}
   143    146       sed -i "${pos}d" ${QFILE}
   144    147   }
   145    148   
   146    149   open_doc () {
          150  +    # Open a document using OPENCMD
   147    151       check_pos
   148    152       $(printf "$OPENCMD" "$(get_doc $pos)")
   149    153       printf "%s READ %s\n" "$(date '+[%Y-%m-%d %H:%M]')" \
   150    154              "$(sed -n "${pos}p" ${QFILE})" >>${LOGFILE}
   151    155       rem_doc
   152    156   }
   153    157   
   154    158   print_bib () {
   155         -    if ! grep -q $1 $2; then
          159  +    # Print the bibliographic information for a document if available
          160  +    local key="$1"
          161  +    local bibfile="$2"
          162  +    if ! grep -q "$key" "$bibfile"; then
   156    163           return
   157    164       fi
   158    165       if [ -f ${BIBCACHE} ]; then
   159         -        wrapped_bib="$(echo "$1" | zdbf ${BIBCACHE} 2>/dev/null)"
          166  +        wrapped_bib="$(echo "$key" | zdbf ${BIBCACHE} 2>/dev/null)"
   160    167       fi
   161    168       if [[ "x$wrapped_bib" == "x" ]]; then
   162         -        wrapped_bib="$(paperbib -a${MAXAUTHORS} -w${WRAP} -i'	' $1 <$2 2>/dev/null)"
          169  +        wrapped_bib="$(paperbib -a${MAXAUTHORS} -w${WRAP} -i'	' $key <$2 2>/dev/null)"
   163    170       fi
   164    171       printf "%s:%s\n\n" "$pos" "$wrapped_bib"
   165    172   }
   166    173   
   167    174   doc_info () {
   168    175       # Print information on the document: bibliographic data unless the -f
   169    176       # option was used.
................................................................................
   214    221       done <${QFILE}
   215    222       dir=$(pwd)
   216    223       cd /tmp && tar -czf $dir/paperq-papers.tar.gz paperq-papers
   217    224       rm -rf /tmp/paperq-papers
   218    225   }
   219    226   
   220    227   check_pos () {
          228  +    # Do some sanity checks on a given queue position
   221    229       if [ ! -e ${QFILE} ]; then
   222    230           printf "The queue has not yet been created.  Add some documents to it "
   223    231           printf "first.\n"
   224    232           exit 1
   225    233       fi
   226    234       len=$(sed '/^ *$/d' ${QFILE} | wc -l | cut -f1 -d' ')
   227    235       if (( len == 0 )); then