diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-11-02 10:59:38 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-11-02 10:59:38 -0700 |
commit | c71fbb18e1655a19215e681ab9064e5e6212d11c (patch) | |
tree | 3582ce157bf2c67b9b50641002c3ee8c66e1d6f4 | |
parent | c0e0ef12cf2b81b69815ac0b5a9f2b5e405d5f1b (diff) | |
download | pandoc-c71fbb18e1655a19215e681ab9064e5e6212d11c.tar.gz |
Improve test/grofftest.sh.
Use --resource-path.
Use iconv for latin1 man pages.
Recurse into subdirectories.
-rw-r--r-- | test/grofftest.sh | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/test/grofftest.sh b/test/grofftest.sh index ca1aa71d9..8c7240aa7 100644 --- a/test/grofftest.sh +++ b/test/grofftest.sh @@ -1,22 +1,26 @@ #!/bin/bash -# iterates over specified directory, containing "\w+\.\d"-like files, -# executes pandoc voer them and prints stderr on nonzero return code +# iterates recursively over specified directory, tries to convert +# man pages and prints to stderr on errors. -if [ $# -ne 2 ]; then +# if called with two arguments, the first is the path to pandoc, +# and the second is the directory. if with one argument, it +# is the directory, and pandoc is used from path. + +if [ $# -eq 2 ]; then + PANDOC=$1 + DIR=$2 +elif [ $# -eq 1 ]; then + PANDOC=pandoc + DIR=$1 +else echo "Not enough arguments" exit 1 fi -PANDOC=$1 -DIR=$2 - $PANDOC --version > /dev/null || { echo "pandoc executable error" >&2 ; exit 1 ; } -ls $2 | egrep "^.+\.[0-9].?$" | while read f ; do - FILE="$DIR/$f" - $PANDOC -f man -t native < $FILE 2>&1 > /dev/null - if [ $? -ne 0 ]; then - echo "Failed to convert $FILE" - fi +for f in `find "$DIR" -name '*.[0-9]'`; do + ( iconv -f utf8 -t utf8 $f 2>/dev/null || iconv -f latin1 -t utf8 $f ) | \ + $PANDOC --resource-path "$DIR":. -f man -o /dev/null || echo "Failed to convert $f" done |