plan9fox/rc/bin/doc2txt
Ori Bernstein 5bc9b0c3ca improve usage messages (thanks henesy)
Fix inconsistencies between programs and their usage
messages,  correct instances where information seems
to be missing or lost. This  includes missing arguments,
making usage consistent with manuals, and so on.
2020-03-10 10:09:34 -07:00

32 lines
563 B
Bash
Executable file

#!/bin/rc
rfork en
if(! ~ $#* 0 1) {
echo 'usage: doc2txt [file.doc]' >[1=2]
exit usage
}
switch($#*){
case 0
cat >/tmp/doc2txt.$pid
file=/tmp/doc2txt.$pid
case 1
file=$1
}
aux/olefs $file || {
echo 'doc2txt: couldn''t mount word document' >[1=2]
rm -f /tmp/doc2txt.$pid
exit word
}
if(! test -f /mnt/doc/WordDocument) {
echo 'doc2txt: is an msoffice doc but not a word document' >[1=2]
rm -f /tmp/doc2txt.$pid
exit worddoc
}
aux/mswordstrings /mnt/doc/WordDocument | tcs -f microsoft -t utf |fmt | uniq
unmount /mnt/doc
rm -f /tmp/doc2txt.$pid