changeset 736:b308d8e4c8ad

check-ports: explicitely allow comments and empty lines in package-mapping.conf
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 07 Oct 2024 16:15:24 +0200
parents 5379b253e8f2
children 907cbedee676
files sbin/check-ports
diffstat 1 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/check-ports	Mon Oct 07 15:51:06 2024 +0200
+++ b/sbin/check-ports	Mon Oct 07 16:15:24 2024 +0200
@@ -210,14 +210,27 @@
     '
     local _package _n _mapped
 
+    local -
+    set -x
+    
     _package="$1"
 
     if [ -r "${PACKAGE_MAPPING}" ] ; then
-        while read -r _n _mapped ; do
-            if [ "${_n}" = "${_package}" ] ; then
-                printf '%s' "${_mapped}"
-                return 0
-            fi
+        while IFS=$' \t' read -r _n _mapped ; do
+            case "${_n}" in
+                '')
+                    # empty line
+                    continue;;
+                \#*)
+                    # comment
+                    continue;;
+                *)
+                    if [ "${_n}" = "${_package}" ] ; then
+                        printf '%s' "${_mapped}"
+                        return 0
+                    fi
+                    ;;
+            esac
         done < "${PACKAGE_MAPPING}"
     fi
     return 1