Skip to contentSkip to conversation

Gracefully handle an unsupported distro.

PATCH In review Doug Goldstein 2 participants 2 messages Aug 18, 2015 – Sep 7, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Gracefully handle an unsupported distro.

When your distro is not supported, handle the case gracefully and let the user know instead of spitting out bash errors.

---
 lib/common-functions.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/common-functions.sh +11 -0
index efde84c..c52174a 100644
@@ -176,6 +176,7 @@ function get_distro() {
             ;;
         *)
             DISTRO=$os_VENDOR
+            PKGTYPE="unknown"
             ;;
     esac
 
@@ -220,6 +221,16 @@ function _install-package-rpm() {
     $SUDO yum install -y $* > /dev/null
 }
 
+function _check-package-unknown() {
+    error_echo "I don't know distro $DISTRO. It might be missing packages."
+    return 1
+}
+
+function _install-package-unknown() {
+    error_echo "I don't know distro $DISTRO. Cannot install packages."
+    return 1
+}
+
 # Modifies inherited variable "missing"
 function check-package() {
     for p in $*
Signature · 1 line
2.4.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Doug Goldstein

When your distro is not supported, handle the case gracefully and let the user know instead of spitting out bash errors.

Thanks for the patch!

Quoted 32 lines
 lib/common-functions.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/common-functions.sh +11 -0
index efde84c..c52174a 100644
@@ -176,6 +176,7 @@ function get_distro() {
             ;;
         *)
             DISTRO=$os_VENDOR
+            PKGTYPE="unknown"
             ;;
     esac
 
@@ -220,6 +221,16 @@ function _install-package-rpm() {
     $SUDO yum install -y $* > /dev/null
 }
 
+function _check-package-unknown() {
+    error_echo "I don't know distro $DISTRO. It might be missing packages."
+    return 1
+}
+
+function _install-package-unknown() {
+    error_echo "I don't know distro $DISTRO. Cannot install packages."
+    return 1
+}
+
 # Modifies inherited variable "missing"
 function check-package() {
     for p in $*