dtstyle: Coverity 89011
[oweals/cde.git] / cde / util / scripts / syminst.sh
1 #!/bin/sh
2 # $XConsortium: syminst.sh /main/2 1995/07/19 18:05:57 drk $
3
4 #
5 # syminst - install with a symbolic link back to the build tree
6 #
7
8 # set DOITPROG to echo to test this script
9
10 doit="${DOITPROG-}"
11
12
13 # put in absolute paths if you don't have them in your path; or use env. vars.
14
15 lnprog="${LNPROG-ln -s}"
16 rmprog="${RMPROG-rm}"
17
18 instcmd="$lnprog"
19 rmcmd="$rmprog -f"
20 srcdir=`pwd`/
21 src=""
22 dst=""
23
24 while [ x"$1" != x ]; do
25     case $1 in
26         -c) shift
27             continue;;
28
29         -m) shift
30             shift
31             continue;;
32
33         -o) shift
34             shift
35             continue;;
36
37         -g) shift
38             shift
39             continue;;
40
41         -s) shift
42             continue;;
43
44         -DIR) srcdir=`echo $2 | sed 's;/\./;/;g'`/
45               shift
46               shift
47               continue;;
48
49         *)  if [ x"$src" = x ]
50             then
51                 src=$1
52             else
53                 dst=$1
54             fi
55             shift
56             continue;;
57     esac
58 done
59
60 if [ x"$src" = x ]
61 then
62         echo "syminst:  no input file specified"
63         exit 1
64 fi
65
66 if [ x"$dst" = x ]
67 then
68         echo "syminst:  no destination specified"
69         exit 1
70 fi
71
72
73 # if destination is a directory, append the input filename; if your system
74 # does not like double slashes in filenames, you may need to add some logic
75
76 if [ -d $dst ]
77 then
78         dst="$dst"/`basename $src`
79 fi
80
81 case $src in
82     /*) srcdir=""
83         instcmd=cp;;
84 esac
85
86 # get rid of the old one and mode the new one in
87
88 $doit $rmcmd $dst
89 $doit $instcmd $srcdir$src $dst
90
91 exit 0