Debian Codegraph @

samples/keepviewer

raw
1 #!/bin/sh
2 # This script can be invoked as a wrapper for an external viewer by lynx, e.g.,
3 # given this line in lynx.cfg
4 # XLOADIMAGE_COMMAND:keepviewer xli %s &
5 # it will invoke xli on a hardlink to the file (which is assumed to be in the
6 # temporary directory created by lynx), and clean up when the viewer exits.
7 #
8 # Parameters:
9 # $1 is viewer
10 # $2 is filename
11 if test $# = 2 ; then
12 chmod 600 $2
13 myfile=`echo $2 | sed -e 's@\(.*/tmp/\)\([^/]*/\)\?\(.*\)@\1my\3@'`
14 ln $2 $myfile || exit 1
15 trap "rm -f $myfile" 0 1 2 5 15
16 eval $1 $myfile
17 else
18 echo "Usage: keepviewer <viewer> <filename>"
19 exit 1
20 fi