Browse Source

Use read builtin safely

Alois Mahdal 6 years ago
parent
commit
257097e88c
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      bin/notifirc

+ 4
- 4
bin/notifirc View File

15
     local message
15
     local message
16
     echo "NICK $nick"
16
     echo "NICK $nick"
17
     echo "USER $nick 8 * :notifirc bot"
17
     echo "USER $nick 8 * :notifirc bot"
18
-    while read message;
18
+    while read -r message;
19
     do
19
     do
20
         echo "PRIVMSG $user :$message"
20
         echo "PRIVMSG $user :$message"
21
     done
21
     done
45
 
45
 
46
 log_pipe() {
46
 log_pipe() {
47
     local line
47
     local line
48
-    while IFS= read line;
48
+    while IFS= read -r line;
49
     do
49
     do
50
         log "$line"
50
         log "$line"
51
     done
51
     done
84
     while true;
84
     while true;
85
     do
85
     do
86
         test $lines_read -ge $limit_l && break
86
         test $lines_read -ge $limit_l && break
87
-        IFS= read line || break
87
+        IFS= read -r line || break
88
         (( lines_read++ ))
88
         (( lines_read++ ))
89
         test ${#line} -gt $limit_c && suff=…
89
         test ${#line} -gt $limit_c && suff=…
90
         line=${line:0:$limit_c}$suff
90
         line=${line:0:$limit_c}$suff
99
         echo "$HOME/.notifirc.log"
99
         echo "$HOME/.notifirc.log"
100
         echo /tmp/notifirc.log
100
         echo /tmp/notifirc.log
101
     } \
101
     } \
102
-      | while read path;
102
+      | while read -r path;
103
         do
103
         do
104
             if test -w "$(dirname "$path")" \
104
             if test -w "$(dirname "$path")" \
105
              || test -w "$path";
105
              || test -w "$path";