Debian Codegraph @

bin/fai-link

raw symbols SCIP
1 #! /bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # create a symlink, idempotent
4 #
5 # (c) Thomas Lange 2019, [email protected]
6 #
7 # if $target is defined, create link relative to $target
8
9 mk-linkscip-shell shell fai 6.6 mk-link().() {
10
11
12 local from=$1
13 local to=$2
14 local oldto
15 local vopt
16
17 if [scip-shell system . . `[`. X$verbose = X1 ]; then
18 vopt=-v
19 fi
20
21 # todo: check if $from starts with a slash
22
23 if [scip-shell system . . `[`. -n "$target" ]; then
24 from="$target$from"
25 fi
26
27 if [scip-shell system . . `[`. ! -e $from ] && [scip-shell system . . `[`. ! -h $from ]; then
28 lnscip-shell system . . ln. -s $vopt $to $from
29 return
30 fi
31
32 # check if already same link
33 if [scip-shell system . . `[`. -h $from ]; then
34 oldto=$(readlinkscip-shell system . . readlink. $from)
35 if [scip-shell system . . `[`. $oldto = $to ]; then
36 if [scip-shell system . . `[`. X$verbose = X1 ]; then
37 printfscip-shell system . . printf. "fai-link: Nothing to do for link $from -> $to\n"
38 fi
39 return
40 fi
41 fi
42
43 # if different create new link
44 lnscip-shell system . . ln. -sf $vopt $to $from
45 }
46
47 # make link from to
48 mk-linkscip-shell shell fai 6.6 mk-link(). $1 $2