From c71fbb18e1655a19215e681ab9064e5e6212d11c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 2 Nov 2018 10:59:38 -0700 Subject: Improve test/grofftest.sh. Use --resource-path. Use iconv for latin1 man pages. Recurse into subdirectories. --- test/grofftest.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'test') 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 -- cgit v1.2.3