Skip to content

Commit

Permalink
Only use 'antiword' in 'astextplain' if 'file' identified a Word docu…
Browse files Browse the repository at this point in the history
…ment

Signed-off-by: Björn Kautler <[email protected]>
  • Loading branch information
Vampire committed Aug 15, 2022
1 parent ab94114 commit ca31d44
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion git-extra/astextplain
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ case "$1" in
odt2txt "$1" || cat "$1"
;;
*.doc | *.DOC | *.dot | *.DOT)
out=$(antiword -m UTF-8 "$1") && sed "s/\^M$//" <<<$out || cat "$1"
case "$(file --brief --mime-type "$1")" in
application/msword)
out=$(antiword -m UTF-8 "$1") && sed "s/\^M$//" <<<$out || cat "$1"
;;
*)
cat "$1"
;;
esac
;;
*.docx | *.DOCX | *.dotx | *.DOTX | *.docm | *.DOCM | *.dotm | *.DOTM)
docx2txt.pl "$1" - || cat "$1"
Expand Down

0 comments on commit ca31d44

Please sign in to comment.