: nply/git-summary

commit 0b2faf7952985d8d38834fa943dc3e192fcd466d
parent 51f0b88cab5bc1a098b55b3eb23739d9154c8137
Author: Mirko Ledda <mirko.ledda@uni.lu>
Date: Wed, 7 Jul 2021 15:29:49 +0200

More helpful error message for failed OS detection
1 file changed, 12 insertions(+), 11 deletions(-)
M
git-summary
|
23
++++++++++++-----------
diff --git a/git-summary b/git-summary
@@ -125,23 +125,24 @@ git_summary() {
 
 # Autodetect the OS
 detect_OS() {
-  if [ "$(uname)" == "SunOS" ]; then  # SunOS (solaris/smartos/illumos)
-    OS=SunOS                                                                                                                                                 
-    readlink_cmd="greadlink"                                                                                                                                 
-    dirname_cmd="gdirname"
-    gawk_cmd="awk"
-  elif [ "$(uname)" == "Darwin" ]; then  # macOS
+
+  if [ "$(uname)" == "Darwin" ]; then  # macOS
     OS=Darwin
     readlink_cmd="greadlink"
     dirname_cmd="gdirname"
     gawk_cmd="awk"
-  elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then  # Linux
-    if [[ $(cat /proc/version) == *"Chromium OS"* ]]; then
+  elif [ "$(uname)" == "SunOS" ]; then  # SunOS (solaris/smartos/illumos)
+    OS=SunOS                                                                                                                                                 
+    readlink_cmd="greadlink"                                                                                                                                 
+    dirname_cmd="gdirname"
+    gawk_cmd="awk"
+  elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then  # Linux-based system
+    if [[ $(cat /proc/version) == *"Chromium OS"* ]]; then  # Chromium OS
       OS=Linux
       readlink_cmd="readlink"
       dirname_cmd="dirname_zero"
       gawk_cmd="gawk"
-    else
+    else  # Vanilla Linux
       OS=Linux
       readlink_cmd="readlink"
       dirname_cmd="dirname"

@@ -153,7 +154,8 @@ detect_OS() {
     dirname_cmd="dirname"
     gawk_cmd="gawk"
   else
-    echo "Cannot identify OS."
+    echo "Oups, I cannot identify your current OS."
+    echo "Please open a ticket or a pull request so we can add your OS to the list of supported systems."
     exit 1
   fi
 }

@@ -329,4 +331,3 @@ max_len () {
 trap "printf '$NC'" EXIT
 
 git_summary $@
-