I'd always check lsb_release -i
first and then check
/etc/os-release
as the fallback. It should be available on many
distributions but you can never count on it being everywhere of
course. It's Freedesktop
standard
and is present on systemd
systems. On
Slackware it shows:
$ cat /etc/os-release
NAME=Slackware
VERSION="14.2"
ID=slackware
VERSION_ID=14.2
PRETTY_NAME="Slackware 14.2"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:slackware:slackware_linux:14.2"
HOME_URL="http://slackware.com/"
SUPPORT_URL="http://www.linuxquestions.org/questions/slackware-14/"
BUG_REPORT_URL="http://www.linuxquestions.org/questions/slackware-14/"
And on Raspbian:
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
The field you're interested here is probably ID
.
apt
andyum
, instead of trying to write an installer that does the right thing? Or write a Linuxbrew formula? – Kusalananda Dec 07 '19 at 20:26