fix OS name detection

before applying heuristics, use PRETTY_NAME from os-release(3),
which reliably exists on all common linux distributions.

keep the /etc/issue parsing as fallback.
This commit is contained in:
Daniel Molkentin
2020-09-18 00:15:04 +02:00
committed by Lukas Schauer
parent b3abc41dbe
commit 5f8cfa50ba

View File

@@ -1369,6 +1369,10 @@ command_version() {
echo ""
if [[ "${OSTYPE}" =~ "BSD" ]]; then
echo "OS: $(uname -sr)"
elif [[ -e /etc/os-release ]]; then
( . /etc/os-release && echo "OS: $PRETTY_NAME" )
elif [[ -e /usr/lib/os-release ]]; then
( . /usr/lib/os-release && echo "OS: $PRETTY_NAME" )
else
echo "OS: $(cat /etc/issue | grep -v ^$ | head -n1 | _sed 's/\\(r|n|l) .*//g')"
fi