This piece of code assign the output of the lsb_release -i
command at the linux_distro
variable and the script compares it against the first item of distributor_id
array and then the second and so on. The first item of the array is "Distributor ID: Arch"
and I am using arch so the linux_distro
variable is supposed to be equal with the item of the array. Of course since I am posting here this does not seem to be the case.
if [ "$linux_distro" = "${distributor_id[0]}" ] || [ "$linux_distro" = "${distributor_id[1]}" ]; then
#checking if the yay AUR helper is available (it will be needed for some of the software installed)
if ! command -v snap > /dev/null; then
echo "yay command was not found. Please install the yay AUR helper aur.archlinux.org/packages/yay from and try running the script again."
exit 1
fi
fi
I tried printing out the variable values using echo
that proved to me that everything is supposed to work as intended and I tried using the [[
command with the ==
operator, still no solution.
It is to be noted that I replaced yay with snap just because I got yay installed and not snap, so please don't bother with that one.
CodePudding user response:
I do not see any syntax error in your code. As a result, I guess the two string are not really equal to each other. On my system, the result of lsb_release -i
is separated by a tab ('\t'). Maybe your other string is separated by a space.
Also, as a suggestion, you can source /etc/os-release
file in your script. Then you can simply compare the value of $ID
variable for determining the distribution.
CodePudding user response:
you can source /etc/os-release
. /etc/os-release
if [ "$ID" = "${distributor_id[0]}" ] || [ "$ID" = "${distributor_id[1]}" ]; then
#checking if the yay AUR helper is available (it will be needed for some of the software installed)
if ! command -v snap > /dev/null; then
echo "yay command was not found. Please install the yay AUR helper aur.archlinux.org/packages/yay from and try running the script again."
exit 1
fi
fi
this file is not exists on all linux distro