astextplain: Try to workaround textconv vs symlinks problem on win32
[msysgit/kirr.git] / bin / astextplain
blobab259b9ad414192b7a5b51c723a552d9250fce4a
1 #!/bin/sh -e
2 # minimalistic replacement for `run-mailcap --action=cat <file>`
4 if test "$#" != 1 ; then
5 echo "Usage: astextplain <file>" 1>&2
6 exit 1
7 fi
9 # small files are never .doc or .pdf -- they are unsupported-on-win32 symlinks
10 # which git just stores as regular files with symlink content
11 if test $(du -b "$1" | awk '{print $1}') -lt 256 ; then
12 cat "$1"
13 exit 0
17 # XXX output encoding (UTF-8) hardcoded
18 case "$1" in
19 *.doc | *.DOC | *.dot | *.DOT)
20 antiword -m UTF-8 "$1" || cat "$1"
22 *.docx | *.DOCX)
23 docx2txt "$1" -
25 *.pdf | *.PDF)
26 pdftotext -layout "$1" -enc UTF-8 -
28 # TODO add rtf support
29 *.rtf | *.RTF)
30 cat "$1"
33 echo "E: unsupported filetype $1" 1>&2
34 exit 1
36 esac
38 exit 0