Browse Source

Make commented-line removal more explicit

Alois Mahdal 6 years ago
parent
commit
5dda7e1a43
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      src/include/ini.sh

+ 8
- 2
src/include/ini.sh View File

@@ -30,13 +30,19 @@ __ini_expand() {
30 30
     done
31 31
 }
32 32
 
33
+__ini_grepcmt() {
34
+    #
35
+    # Remove comments from INI file on stdin
36
+    #
37
+    grep -v '^[[:space:]]*#'
38
+}
39
+
33 40
 __ini_grepkey() {
34 41
     #
35 42
     # Read key from a section
36 43
     #
37 44
     local wnt=$1    # wanted key
38 45
     grep '.' \
39
-      | grep -v '\s*#' \
40 46
       | sed -e 's/ *= */=/; s/ +$//; s/^//;' \
41 47
       | grep -e "^$wnt=" \
42 48
       | cut -d= -f2- \
@@ -127,7 +133,7 @@ __ini_body() {
127 133
         grep -vx "$incre" "$MKIT_INI"
128 134
     else
129 135
         cat "$MKIT_INI"
130
-    fi
136
+    fi | __ini_grepcmt
131 137
 }
132 138
 
133 139
 ini() {