| 1 | #! /bin/bash |
| 2 | |
| 3 | if [ $# == 0 ] || [ $# == 1 ] |
| 4 | then |
| 5 | cat <<EOF |
| 6 | Usage: $0 ( BIBFILE | AUXFILE ) ... DESTDIR |
| 7 | This script runs bibtool with many different arguments and is |
| 8 | intended to help comparing the behaviour of old and new bibtool |
| 9 | binaries when updating the package. Use at your own risk. |
| 10 | It produces a many files named DESTDIR/testout:*, and all such |
| 11 | files are removed if they already exist. |
| 12 | DESTDIR will be created if it does not already exist. |
| 13 | EOF |
| 14 | exit 100 |
| 15 | fi |
| 16 | |
| 17 | : ${BIBTOOL='bibtool'} |
| 18 | |
| 19 | AUXFILES= |
| 20 | BIBFILES= |
| 21 | IBIBFILES= |
| 22 | while [ $# != 1 ] |
| 23 | do |
| 24 | case $1 in |
| 25 | *.aux) |
| 26 | AUXFILES="$AUXFILES $1" |
| 27 | ;; |
| 28 | *) [ -r $1 ] || (echo $1: not found ; false) || exit 2 |
| 29 | BIBFILES="$BIBFILES $1" |
| 30 | IBIBFILES="$IBIBFILES -i $1" |
| 31 | ;; |
| 32 | esac |
| 33 | shift |
| 34 | done |
| 35 | |
| 36 | DESTDIR=$1 ; |
| 37 | [ -d $DESTDIR ] || mkdir $DESTDIR || exit 1 |
| 38 | |
| 39 | rm -f $DESTDIR/testout:* |
| 40 | echo $AUXFILES > $DESTDIR/testout:context |
| 41 | echo $BIBFILES >> $DESTDIR/testout:context |
| 42 | export >> $DESTDIR/testout:context |
| 43 | |
| 44 | [ "$BIBFILES" ] || (echo No bibfiles given ; false) || exit 2 |
| 45 | |
| 46 | iomode=a |
| 47 | for acode in : -h -k:-v -k:-A0 -K:-Aa -k:-AA -s -S:-q \ |
| 48 | -r:braces -r:check_y -r:improve -r:opt -r:sort_fld -r:tex_def \ |
| 49 | nosuchfile |
| 50 | do |
| 51 | args=`echo $acode | tr : ' '` |
| 52 | stdout=$DESTDIR/testout:$acode |
| 53 | stderr=${stdout}@2 |
| 54 | case $iomode in |
| 55 | a) |
| 56 | cmd="$BIBTOOL $args -m ${stdout}@m" |
| 57 | echo cat $BIBFILES "|" $cmd ">" $stdout |
| 58 | cat $BIBFILES | $cmd > $stdout 2> $stderr |
| 59 | ;; |
| 60 | aa) |
| 61 | echo $BIBTOOL $IBIBFILES $args ">" $stdout |
| 62 | $BIBTOOL $IBIBFILES $args > $stdout 2> $stderr |
| 63 | ;; |
| 64 | *) |
| 65 | iomode= |
| 66 | cmd="$BIBTOOL $args -M - -o $stdout $BIBFILES" |
| 67 | echo $cmd ">" ${stdout}@M |
| 68 | $cmd > ${stdout}@M 2> $stderr |
| 69 | ;; |
| 70 | esac |
| 71 | echo [exit code $?] >> $stderr |
| 72 | iomode=a$iomode |
| 73 | done |
| 74 | |
| 75 | for auxfile in $AUXFILES |
| 76 | do |
| 77 | stdout=$DESTDIR/testout:-x`echo $auxfile | tr / :` |
| 78 | stderr=${stdout}@2 |
| 79 | echo $BIBTOOL -x $auxfile ">" $stdout |
| 80 | $BIBTOOL -x $auxfile > $stdout 2> $stderr |
| 81 | echo [exit code $?] >> $stderr |
| 82 | done |
| 83 | |
| 84 | exit 0 |