summaryrefslogtreecommitdiff
path: root/compare_versions.sh
blob: 757100d6bf48932dff794d0f63efe716126b5bec (plain)
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
#!/bin/bash

# Bash script to compare ungoogled-chromium version numbers
# $1 -> up-to-date version number (from atom feed)
# $2 -> currently installed version number
# Return Values:
	# 0 -> installed version is up-to-date
	# 1 -> installed version can be upgraded


# Break into arrays
IFS='.'
read -ra V1 <<< "$1"
read -ra V2 <<< "$2"

# Determine shorter array (for the loop)
LENGTH=${#V1[@]}

for (( i = 0 ; i < LENGTH ; i++ )); do
	if [ "${V1[$i]}" -gt "${V2[$i]}" ]; then
		exit 1
	elif [ "${V1[$i]}" -lt "${V2[$i]}" ]; then
		exit 0
	fi
done

exit 0