Improve test/grofftest.sh.
Use --resource-path. Use iconv for latin1 man pages. Recurse into subdirectories.
This commit is contained in:
parent
c0e0ef12cf
commit
c71fbb18e1
1 changed files with 16 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue