Not logged in

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

Overview
Comment:clean up indentation
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:844f122db45f7731bfb544ee23bdc04f8954612a
User & Date: brandon 2016-04-06 20:02:17
Context
2016-04-06
20:30
normalize and improve usage of quotes, printf vs echo and subshells check-in: ee4fbdb256 user: brandon tags: trunk
20:02
clean up indentation check-in: 844f122db4 user: brandon tags: trunk
19:59
fix [4bcc9f] check-in: 392dd493b1 user: brandon tags: trunk
Changes

Changes to paperq.in.

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
    echo "`date '+[%Y-%m-%d %H:%M]'` READ    `sed -n "$1p" ${QFILE}`" >>${LOGFILE}
    rem_doc
}

print_bib () {
    if ! grep -q $1 $2; then
        return
    fi 
    if [ -f ${BIBCACHE} ]; then
        wrapped_bib="`echo $1 | zdbf ${BIBCACHE} 2>/dev/null`"
    fi
    if [[ "x$wrapped_bib" == "x" ]]; then
        wrapped_bib="`paperbib -a${MAXAUTHORS} -w${WRAP} -i'	' $1 <$2 2>/dev/null`"
    fi
    printf "%s:${wrapped_bib}\n\n" $pos
}

doc_info () {
# Print information on the document: bibliographic data unless the -f
# option was used.
    local doc=`get_doc`
    local key=`basename ${doc} .pdf`
    if $files; then
        printf "`get_doc`\n"
    elif [[ "x$BIBTEXDIR" != "x" ]]; then
        for bibfile in "${BIBTEXDIR}"/*.bib; do
            print_bib "${key}" "${bibfile}"
................................................................................
    else
        printf "No bibtex file specified.  Set either 'bibtex-file FILE' or \
'bibtex-dir DIR' in ${CONFFILE}\n"
    fi
}

list_docs () {
# List all of the documents in the queue
    local numdocs
    if $files || [[ "x$BIBTEXFILE" == "x" && "x$BIBTEXDIR" == "x" ]]; then
        awk '{print FNR": \t" $1}' ${QFILE}
    else
        numdocs=`sed '/^ *$/d' ${QFILE} | wc -l | cut -f1 -d' '`
        if [[ "$numdocs" == "0" ]]; then
            return
................................................................................
        for pos in `seq 1 $numdocs`; do
            doc_info false
        done
    fi
}

archive_queue () {
# Make a tarball of all the papers in the queue
    mkdir /tmp/paperq-papers
    local -i n=1
    while read line; do
        paper_file=`basename $line`
        if (( n < 10 )); then
            cp $line /tmp/paperq-papers/0${n}_$paper_file
        else
................................................................................
    elif [ $pos -gt $len ]; then
        printf "The specified position is larger than the queue length.\n"
        exit 1
    fi
}

parse_conf () {
# Parse the configuration file
    while read option value; do
        case "$option" in
            bibtex-file) BIBTEXFILE="$value";;
            bibtex-dir) BIBTEXDIR="$value";;
            wrap) WRAP="$value";;
            max-authors) MAXAUTHORS="$value";;
            open-cmd) OPENCMD="$value";;
................................................................................
        n) pos=$OPTARG ;;
        \?) echo "Invalid option: -$OPTARG" && exit 1;;
    esac
done

case $mode in
    add_doc) shift; \
        for doc in "$@"; do \
            add_doc "`realpath "$doc"`"; \
        done;;
    list_docs) list_docs ;;
    doc_info) doc_info ;;
    rem_doc) rem_doc ;;
    open_doc) open_doc ;;
    peek_doc) $(printf "$OPENCMD" `get_doc $pos`) ;;
    print_doc) $(printf "$PRINTCMD" `get_doc $pos`) ;;
    archive_queue) archive_queue ;;
esac







|










|
|







 







|







 







|







 







|







 







|
|
|








147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
    echo "`date '+[%Y-%m-%d %H:%M]'` READ    `sed -n "$1p" ${QFILE}`" >>${LOGFILE}
    rem_doc
}

print_bib () {
    if ! grep -q $1 $2; then
        return
    fi
    if [ -f ${BIBCACHE} ]; then
        wrapped_bib="`echo $1 | zdbf ${BIBCACHE} 2>/dev/null`"
    fi
    if [[ "x$wrapped_bib" == "x" ]]; then
        wrapped_bib="`paperbib -a${MAXAUTHORS} -w${WRAP} -i'	' $1 <$2 2>/dev/null`"
    fi
    printf "%s:${wrapped_bib}\n\n" $pos
}

doc_info () {
    # Print information on the document: bibliographic data unless the -f
    # option was used.
    local doc=`get_doc`
    local key=`basename ${doc} .pdf`
    if $files; then
        printf "`get_doc`\n"
    elif [[ "x$BIBTEXDIR" != "x" ]]; then
        for bibfile in "${BIBTEXDIR}"/*.bib; do
            print_bib "${key}" "${bibfile}"
................................................................................
    else
        printf "No bibtex file specified.  Set either 'bibtex-file FILE' or \
'bibtex-dir DIR' in ${CONFFILE}\n"
    fi
}

list_docs () {
    # List all of the documents in the queue
    local numdocs
    if $files || [[ "x$BIBTEXFILE" == "x" && "x$BIBTEXDIR" == "x" ]]; then
        awk '{print FNR": \t" $1}' ${QFILE}
    else
        numdocs=`sed '/^ *$/d' ${QFILE} | wc -l | cut -f1 -d' '`
        if [[ "$numdocs" == "0" ]]; then
            return
................................................................................
        for pos in `seq 1 $numdocs`; do
            doc_info false
        done
    fi
}

archive_queue () {
    # Make a tarball of all the papers in the queue
    mkdir /tmp/paperq-papers
    local -i n=1
    while read line; do
        paper_file=`basename $line`
        if (( n < 10 )); then
            cp $line /tmp/paperq-papers/0${n}_$paper_file
        else
................................................................................
    elif [ $pos -gt $len ]; then
        printf "The specified position is larger than the queue length.\n"
        exit 1
    fi
}

parse_conf () {
    # Parse the configuration file
    while read option value; do
        case "$option" in
            bibtex-file) BIBTEXFILE="$value";;
            bibtex-dir) BIBTEXDIR="$value";;
            wrap) WRAP="$value";;
            max-authors) MAXAUTHORS="$value";;
            open-cmd) OPENCMD="$value";;
................................................................................
        n) pos=$OPTARG ;;
        \?) echo "Invalid option: -$OPTARG" && exit 1;;
    esac
done

case $mode in
    add_doc) shift; \
             for doc in "$@"; do \
                 add_doc "`realpath "$doc"`"; \
             done;;
    list_docs) list_docs ;;
    doc_info) doc_info ;;
    rem_doc) rem_doc ;;
    open_doc) open_doc ;;
    peek_doc) $(printf "$OPENCMD" `get_doc $pos`) ;;
    print_doc) $(printf "$PRINTCMD" `get_doc $pos`) ;;
    archive_queue) archive_queue ;;
esac