File: wvMime

package info (click to toggle)
wv 1.2.9-4.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,044 kB
  • ctags: 4,093
  • sloc: ansic: 31,036; sh: 11,951; xml: 1,677; makefile: 21
file content (48 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh 

if [ ${#} -ne "1" ]; then
	echo "Usage: ${0} <word document>"
	exit 1
fi

# check our requirements
type wvPS >/dev/null 2>&1
if [ ${?} -ne "0" ]; then
	echo "Error: required program 'wvPS' was not found"
	exit 1
fi

if [ -z "$GV" ]; then
	# determine the viewer application:
	# - see (let mailcap decide)
	# - ggv (GNOME Ghostview)
	# - kghostview (KDE Ghostview)
	# - gv (Xaw3d Ghostview)
	# - ghostview (the classic Ghostscript frontend)
	for GV in see ggv kghostview gv ghostview; do
		type "$GV" >/dev/null 2>&1 && break
	done
	if [ ${?} -ne "0" ]; then
		# unrecoverable error
		echo "Could not find a suitable PostScript viewer."
		echo "Please install ggv, kghostview, gv, or ghostview"
		exit 1
	fi
fi

# temporary target directory
t_dir=${TMPDIR:-/tmp}/wvMime-$USER-$$
mkdir -m 700 "$t_dir" || exit
trap 'rm -rf "$t_dir"' 0 1 2 3 15

# PS file
name=`basename "$1" .doc`.ps

wvPS --targetdir="$t_dir" "$1" "$name"
if [ ${?} -ne "0" ]; then 
	echo "Could not translate into Postscript" 
	exit 1 
fi 

# call our ghost-viewer
$GV "$t_dir/$name"