3
# Start script for VIPS
5
# need extended regexps, hence we insist on bash above
9
# name we were invoked as
14
echo "usage: $bname [command ...]"
16
echo " $bname man im_invert"
17
echo " $bname vips im_invert /pics/tmp/fred.jpg /pics/tmp/fred2.tif"
21
# prepend a path component to an environment variable
22
# be careful to avoid trailing : characters if the var is not defined, they
23
# can cause security problems
24
function prepend_var () {
25
# we have to use eval to do double indirection, I think
27
if [ "x$value" = x ]; then
34
# try to extract the prefix from a path to an executable
35
# eg. "/home/john/vips/bin/fred" -> "/home/john/vips"
36
function find_prefix () {
37
# try to canonicalise the path
40
# relative path? prefix with pwd
41
if [ ${ep_canon:0:1} != "/" ]; then
42
ep_canon=`pwd`/$ep_canon
45
# replace any "/./" with "/"
46
ep_canon=${ep_canon//\/.\//\/}
48
# any "xxx/../" can go
49
ep_canon=${ep_canon//+([^\/])\/..\//}
51
# trailing "xxx/.." can go
52
ep_canon=${ep_canon/%+([^\/])\/../}
54
# remove trailing "/bin/xxx" to get the prefix
55
ep_prefix=${ep_canon/%\/bin\/+([^\/])/}
57
# was there anything to remove in that final step? if not, the path
59
if [ x$ep_prefix == x$ep_canon ]; then
68
# try to guess the install prefix from $0
69
function guess_prefix () {
70
# $0 is a file? must be us
76
# nope, extract program name from $0 and try looking along the
81
while [ x$fred != x"" ]; do
82
path=${fred/:*/}/$name
83
fred=${fred/*([^:])?(:)/}
91
# not found on path either ... give up!
95
prefix=`guess_prefix`;
98
echo "unable to find $0 from the file name, or from your PATH"
99
echo "either run directly, or add the install bin area to "
104
export VIPSHOME=$prefix
106
# add VIPSHOME to man pages
107
prepend_var MANPATH $VIPSHOME/man
109
# add the VIPS lib area to the library path
116
libvar=DYLD_LIBRARY_PATH
120
libvar=LD_LIBRARY_PATH
123
prepend_var $libvar $VIPSHOME/lib
125
# add VIPS bin area to path
126
prepend_var PATH $VIPSHOME/bin
128
# run, passing in args we were passed