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
     done
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
 __ini_grepkey() {
40
 __ini_grepkey() {
34
     #
41
     #
35
     # Read key from a section
42
     # Read key from a section
36
     #
43
     #
37
     local wnt=$1    # wanted key
44
     local wnt=$1    # wanted key
38
     grep '.' \
45
     grep '.' \
39
-      | grep -v '\s*#' \
40
       | sed -e 's/ *= */=/; s/ +$//; s/^//;' \
46
       | sed -e 's/ *= */=/; s/ +$//; s/^//;' \
41
       | grep -e "^$wnt=" \
47
       | grep -e "^$wnt=" \
42
       | cut -d= -f2- \
48
       | cut -d= -f2- \
127
         grep -vx "$incre" "$MKIT_INI"
133
         grep -vx "$incre" "$MKIT_INI"
128
     else
134
     else
129
         cat "$MKIT_INI"
135
         cat "$MKIT_INI"
130
-    fi
136
+    fi | __ini_grepcmt
131
 }
137
 }
132
 
138
 
133
 ini() {
139
 ini() {