Debian Codegraph @

applications/other/switch-BEDOPS-binary-type

raw
1 #!/bin/bash
2 # author : sjn + apr
3 # date : July.2017
4
5 BINDIR=$(dirname `which bedops` 2> /dev/null)
6 [ -n "${2}" ] && BINDIR=${2}
7
8 CMD="switch-BEDOPS-binary-type"
9
10 help()
11 {
12 echo "Switch the BEDOPS binary build to typical, megarow, or float128"
13 echo "Usage: ${CMD} [ --help ] [ --typical | --megarow | --float128 ] [ <binary-directory> (optional) ]" >&2
14 exit $1
15 }
16
17 TYPICAL=false
18 MEGAROW=false
19 FLOAT128=false
20
21 cntr=0
22
23 OPTSPEC=":tmfh-:"
24 while getopts "$OPTSPEC" OPTCHAR; do
25 case "${OPTCHAR}" in
26 -)
27 case "${OPTARG}" in
28 typical)
29 ((cntr+=1))
30 TYPICAL=true
31 ;;
32 megarow)
33 ((cntr+=1))
34 MEGAROW=true
35 ;;
36 float128)
37 ((cntr+=1))
38 FLOAT128=true
39 ;;
40 help)
41 help 0
42 ;;
43 *)
44 help 1
45 ;;
46 esac;;
47 t)
48 ((cntr+=1))
49 TYPICAL=true
50 ;;
51 m)
52 ((cntr+=1))
53 MEGAROW=true
54 ;;
55 f)
56 ((cntr+=1))
57 FLOAT128=true
58 ;;
59 h)
60 help 0
61 ;;
62 *)
63 help 1
64 ;;
65 esac
66 done
67
68 if [[ "$cntr" -ne "1" ]]
69 then
70 help 1
71 fi
72
73 if ${MEGAROW}
74 then
75 TYPE=megarow
76 fi
77 if ${TYPICAL}
78 then
79 TYPE=typical
80 fi
81 if ${FLOAT128}
82 then
83 TYPE=float128
84 fi
85
86 echo $BINDIR
87 for SRCNAME in `find ${BINDIR} -maxdepth 1 -mindepth 1 -type f -name "*${TYPE}" -print0 | xargs -I{} -0 sh -c 'basename {}' | xargs -L1`
88 do
89 DESTNAME=`echo ${SRCNAME} | perl -Tpe 's/-'${TYPE}'//'`
90 ln -sf ${BINDIR}/${SRCNAME} ${BINDIR}/${DESTNAME}
91 done
92
93 exit 0