#! /bin/sh # special script to view .doc files via mailcap and mc # you can replace lynx by links # mailcap: # application/msword; docview -h %s; needsterminal # application/msword; docview %s; copiousoutput # mc: # View=%view{ascii} docview %f # be secure, noclobber set -C function dv() { if file "$i" | grep -q "Microsoft \(Office\|Word.*\) Document" then mkdir /tmp/docview_d$$ if [ "${i:0:1}" = / ] then ln -s "$i" /tmp/docview_d$$/index.doc else ln -s "$PWD/$i" /tmp/docview_d$$/index.doc fi cd /tmp/docview_d$$ if $USE_HTML then wvHtml index.doc index.html lynx -image_links index.html else wvText index.doc index.txt cat index.txt fi rm -r /tmp/docview_d$$ else cat "$i" fi } USE_HTML=false [ "$1" = -h ] && shift && USE_HTML=true if [ $# -eq 0 -o "$1" = - ] then cat >/tmp/docview$$ dv /tmp/docview$$ rm /tmp/docview$$ else for i in "$@" do dv "$i" done fi