Skip to contentSkip to conversation

Handle unsupported distros with a prettier message

PATCH In review Doug Goldstein 2 participants 2 messages Nov 13, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Handle unsupported distros with a prettier message

Handle unknown distros by saying "unknown" instead of an empty string and for Gentoo users actually mention it.

---
 lib/common-functions.sh | 5 +++++
 1 file changed, 5 insertions(+)
lib/common-functions.sh +5 -0
index 27f6434..19434c2 100644
@@ -98,6 +98,8 @@ function get_tests() {
 }
 
 function get_distro() {
+    os_VENDOR="unknown"
+
     if [[ -x "`which lsb_release 2>/dev/null`" ]]
     then
         os_VENDOR=`lsb_release -i -s`
@@ -150,6 +152,9 @@ function get_distro() {
                      sed -r 's/\"|\(|\)//g' | awk '{print $2}'`
         os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' \
                     | sed 's/\"//g'`
+    elif [[ -f /etc/gentoo-release ]]
+    then
+        os_VENDOR="Gentoo"
     fi
 
     # Simply distro version string
Signature · 1 line
2.4.10
Acked-by on v3 1/1
#1 lore raw
Quoted 4 lines · Doug Goldstein

Handle unknown distros by saying "unknown" instead of an empty string and for Gentoo users actually mention it.

and applied

Quoted 29 lines
 lib/common-functions.sh | 5 +++++
 1 file changed, 5 insertions(+)
lib/common-functions.sh +5 -0
index 27f6434..19434c2 100644
@@ -98,6 +98,8 @@ function get_tests() {
 }
 
 function get_distro() {
+    os_VENDOR="unknown"
+
     if [[ -x "`which lsb_release 2>/dev/null`" ]]
     then
         os_VENDOR=`lsb_release -i -s`
@@ -150,6 +152,9 @@ function get_distro() {
                      sed -r 's/\"|\(|\)//g' | awk '{print $2}'`
         os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' \
                     | sed 's/\"//g'`
+    elif [[ -f /etc/gentoo-release ]]
+    then
+        os_VENDOR="Gentoo"
     fi
 
     # Simply distro version string
Signature · 1 line
2.4.10