Skip to contentSkip to conversation

Handle unsupported distros with a prettier message

PATCH Superseded Doug Goldstein 2 participants 2 messages Nov 11, 2015 – Nov 12, 2015 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/common-functions.sh +8 -0
index 27f6434..a0b8431 100644
@@ -150,8 +150,16 @@ 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
 
+    if [[ -z $os_VENDOR ]]
+	then
+		os_VENDOR="unknown"
+	fi
+
     # Simply distro version string
     case "$os_VENDOR" in
         "Debian"* | "Ubuntu"* | "LinuxMint"* )
Signature · 1 line
2.4.10
#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.

Thanks for the patch.

Quoted 10 lines
 lib/common-functions.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/common-functions.sh +0 -0
index 27f6434..a0b8431 100644
@@ -150,8 +150,16 @@ function get_distro() {
                      sed -r 's/\"|\(|\)//g' | awk '{print $2}'`
         os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' \

lib/common-functions.sh function get_distro() { · line 161

Quoted 10 lines
lib/common-functions.sh +7 -0
                     | sed 's/\"//g'`
+    elif [[ -f /etc/gentoo-release ]]
+    then
+        os_VENDOR="Gentoo"
     fi
 
+    if [[ -z $os_VENDOR ]]
+	then
+		os_VENDOR="unknown"
+	fi

Spaces no tabs, please :-)

If you are going to resend, I would prefer to set os_VENDOR to "unknown" at the beginning of the function and avoid the if.

Quoted 6 lines
lib/common-functions.sh +0 -0
     # Simply distro version string
     case "$os_VENDOR" in
         "Debian"* | "Ubuntu"* | "LinuxMint"* )
Signature · 1 line
2.4.10