Browse Source

Use read builtin safely

Alois Mahdal 7 years ago
parent
commit
9892a15371
3 changed files with 12 additions and 12 deletions
  1. 4
    4
      src/include/build.sh
  2. 5
    5
      src/include/deploy.sh
  3. 3
    3
      src/include/ini.sh

+ 4
- 4
src/include/build.sh View File

68
         do
68
         do
69
             debug_var section
69
             debug_var section
70
             ini lskeys "$section" \
70
             ini lskeys "$section" \
71
-              | while read varname;
71
+              | while read -r varname;
72
                 do
72
                 do
73
                     varvalue="$(ini 1value "$section:$varname" | _qfs )"
73
                     varvalue="$(ini 1value "$section:$varname" | _qfs )"
74
                     echo "s|$varname|$varvalue|g;"
74
                     echo "s|$varname|$varvalue|g;"
116
     #
116
     #
117
     local srcpath
117
     local srcpath
118
     find -type f -name '*.skel' \
118
     find -type f -name '*.skel' \
119
-     | while read srcpath;
119
+     | while read -r srcpath;
120
        do
120
        do
121
            _build1 "$srcpath"
121
            _build1 "$srcpath"
122
        done
122
        done
127
     if command -v ronn >/dev/null;
127
     if command -v ronn >/dev/null;
128
     then
128
     then
129
         ini lskeys "files:man" \
129
         ini lskeys "files:man" \
130
-          | while read manfile;
130
+          | while read -r manfile;
131
             do
131
             do
132
                 mdfile="$manfile.md"
132
                 mdfile="$manfile.md"
133
                 ronn -r "$mdfile"
133
                 ronn -r "$mdfile"
174
     mkdir -p debian/source
174
     mkdir -p debian/source
175
     local dfsrc dftgt
175
     local dfsrc dftgt
176
     find "$debian_skel" -type f \
176
     find "$debian_skel" -type f \
177
-      | while read dfsrc;
177
+      | while read -r dfsrc;
178
         do
178
         do
179
             dftgt="debian/${dfsrc#$debian_skel}"
179
             dftgt="debian/${dfsrc#$debian_skel}"
180
             mkdir -p "$(dirname "$dftgt")"
180
             mkdir -p "$(dirname "$dftgt")"

+ 5
- 5
src/include/deploy.sh View File

31
         _maybe mkdir -vp "$(dirname "$dst")"
31
         _maybe mkdir -vp "$(dirname "$dst")"
32
         _maybe cp -Tvr "$src" "$dst"
32
         _maybe cp -Tvr "$src" "$dst"
33
         find "$dst" -type f \
33
         find "$dst" -type f \
34
-          | while read chmod_item;
34
+          | while read -r chmod_item;
35
             do
35
             do
36
                 _maybe chmod "$mode" "$chmod_item"
36
                 _maybe chmod "$mode" "$chmod_item"
37
             done
37
             done
88
     ini lskeys "files" \
88
     ini lskeys "files" \
89
       | sort \
89
       | sort \
90
       | uniq \
90
       | uniq \
91
-      | while read group;
91
+      | while read -r group;
92
         do
92
         do
93
             mode=$(ini 1value "modes:$group")
93
             mode=$(ini 1value "modes:$group")
94
             ini values "files:$group" \
94
             ini values "files:$group" \
95
-              | while read src dst;
95
+              | while read -r src dst;
96
                 do
96
                 do
97
                     dst=$(_get_dst "$group" "$src" "$dst")
97
                     dst=$(_get_dst "$group" "$src" "$dst")
98
                     _deploy_item "$src" "$dst" "$mode"
98
                     _deploy_item "$src" "$dst" "$mode"
110
     ini lskeys "files" \
110
     ini lskeys "files" \
111
       | sort \
111
       | sort \
112
       | uniq \
112
       | uniq \
113
-      | while read group;
113
+      | while read -r group;
114
         do
114
         do
115
             ini values "files:$group" \
115
             ini values "files:$group" \
116
-              | while read src dst;
116
+              | while read -r src dst;
117
                 do
117
                 do
118
                     dst=$(_get_dst "$group" "$src" "$dst")
118
                     dst=$(_get_dst "$group" "$src" "$dst")
119
                     _maybe rm -vrf "$dst"
119
                     _maybe rm -vrf "$dst"

+ 3
- 3
src/include/ini.sh View File

4
     #
4
     #
5
     # A no-op for text stream
5
     # A no-op for text stream
6
     #
6
     #
7
-    while read line;
7
+    while read -r line;
8
     do
8
     do
9
         printf -- "%s\n" "$line"
9
         printf -- "%s\n" "$line"
10
     done
10
     done
15
     # Expand reference value (prefix only)
15
     # Expand reference value (prefix only)
16
     #
16
     #
17
     local line suffix ref value
17
     local line suffix ref value
18
-    while read line;                        # [foo:bar]/path
18
+    while read -r line;                     # [foo:bar]/path
19
     do
19
     do
20
         suffix="${line#\[*\]}"              # /path
20
         suffix="${line#\[*\]}"              # /path
21
         ref="${line%$suffix}"               # [foo:bar]
21
         ref="${line%$suffix}"               # [foo:bar]
71
     local ok=false
71
     local ok=false
72
     grep '.' \
72
     grep '.' \
73
       | grep -v '\s*#' \
73
       | grep -v '\s*#' \
74
-      | while read line;
74
+      | while read -r line;
75
         do
75
         do
76
             case "$line" in
76
             case "$line" in
77
                 \[$wnt\]) ok=true;  continue ;;
77
                 \[$wnt\]) ok=true;  continue ;;