version check is wrong
There is a problem with these checks:
if [[ "$(pacman -Qq | grep 'nss' -m1)" == "nss" ]] && \
[[ "$(vercmp $(pacman -Q | grep 'nss' -m1 | cut -d' ' -f2) 3.51.1-1)" -lt 0 ]]; then
e.g.:
pacman -Qq | grep 'nss'
will return:
dnssec-anchors
jansson
kdnssd
lib32-nss
lib32-openssl
nss
nss-mdns
openssh
openssl
openssl-1.0
and
pacman -Qq | grep 'nss' -m1
will result
dnssec-anchors
Which is not the package we want. Instead, we should use:
pacman -Qq | grep 'nss' -m1 -x
which will return:
nss
which is the wanted result.
Furthermore:
pacman -Q | grep 'nss'
will return
dnssec-anchors 20190629-2
jansson 2.12-1
kdnssd 5.69.0-1
lib32-nss 3.51.1-1
lib32-openssl 1:1.1.1.g-1
nss 3.51.1-1
nss-mdns 0.14.1-2
openssh 8.2p1-3
openssl 1.1.1.g-1
openssl-1.0 1.0.2.u-1
and
pacman -Q | grep 'nss' -m1
return
dnssec-anchors 20190629-2
and
pacman -Q | grep 'nss' -m1 | cut -d' ' -f2
return
20190629-2
which is also wrong. Instead we should add an extra space:
pacman -Q | grep 'nss ' -m1 | cut -d' ' -f2
will return
3.51.1-1
So the complete check should look like this:
if [[ "$(pacman -Qq | grep 'nss' -m1 -x)" == "nss" ]] && \
[[ "$(vercmp $(pacman -Q | grep 'nss ' -m1 | cut -d' ' -f2) 3.51.1-1)" -lt 0 ]]; then
With an additional -x first, and an extra space for the seconf conditon.
We should change all the package checks like this.