-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathambermd_util.bash
63 lines (58 loc) · 1.28 KB
/
ambermd_util.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
function fail
{
local msg=$1
[ "$msg" ] || msg="No message given."
echo "$msg Exiting"
exit 1
}
function amu_protocol_rm_comment
{
sed -e "/^\s*#/d" -e "/^$/d" -e 's/^\(.*\)#.*$/\1/' $1
}
function amu_protocol_clean
{
amu_protocol_rm_comment <( sed -e "/^\s*|/d" -e "s/\t/ /g" $1 )
#amu_protocol_rm_comment <( sed -e "s/\t/ /g" $1 )
}
function amu_get_project_name
{
delim=${1:--}
local proj=""
local cwd=""
local p=`realpath .`
local ifs=$IFS
local in=""
# for i in $p ; do
# cwd="${cwd}/$i"
# [ -f "${cwd}/IS_BASE" ] && in="1"
# [ $in ] && proj="${proj}-$i"
# [ -f "${cwd}/IS_PROJ" ] && break
# done
# look for IS_PROJ, get count
# if more than one, take ./IS_PROJ since deeper is undefined
IFS="/"
for i in $p ; do
cwd="${cwd}/$i"
if [ -f "${cwd}/IS_BASE" ] ; then
in="1"
fi
[ $in ] && proj="${proj}${delim}$i"
[ -f "${cwd}/IS_PROJ" ] && last=$proj
#if [ $have_proj -eq 0 ] ; then
#[ -f "${cwd}/IS_PROJ" ] && [ "${cwd}" == "/$(realpath .)" ] && break
#else
#fi
done
proj=$last
IFS=$ifs
echo $proj | sed s:^\\${delim}::
}
function amu_get_step
{
p=`pwd`
b=`basename $p`
printf "%d" ${b}
}
PROJ=""
[ -f IS_PROJ ] && PROJ=1