-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollforward.sh
48 lines (39 loc) · 1.03 KB
/
rollforward.sh
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
#!/bin/bash
input="history"
prev=""
live=$( cat current )
next="false"
while IFS= read -r line
do
first=""
second=""
delimiter="@"
string=$line$delimiter
myarray=()
while [[ $string ]]; do
myarray+=( "${string%%"$delimiter"*}" )
string=${string#*"$delimiter"}
done
for value in ${myarray[@]}
do
if [ "$first" == "" ]; then
first="$value"
else
second="$value"
fi
done
if [ "$next" == "true" ]; then
break; break;
fi
if [ "$first" == "$live" ]; then
next="true"
continue;
fi
prev=$first
done < "$input"
if [ "$first" == "" ]; then
echo "No version after $live, stopping..."
exit 0;
fi
echo "> Current version should be: $first from: $second"
echo "$first" > current