Browse Source

Use -r with every `read` (according to ShellCheck)

Alois Mahdal 3 years ago
parent
commit
53c22ff5f5
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      99bottles.sh

+ 4
- 4
99bottles.sh View File

107
     #
107
     #
108
     local oneBottle=false   # 'true' if this line affects the following line
108
     local oneBottle=false   # 'true' if this line affects the following line
109
     local line              # every line
109
     local line              # every line
110
-    while read line; do
110
+    while read -r line; do
111
         line="${line/one more bottles/one more bottle}"
111
         line="${line/one more bottles/one more bottle}"
112
         case "$line" in
112
         case "$line" in
113
             *"one of those bottles"*)   line="$(
113
             *"one of those bottles"*)   line="$(
136
     # Fix capitalization of each line on stdin
136
     # Fix capitalization of each line on stdin
137
     #
137
     #
138
     local line      # every line
138
     local line      # every line
139
-    while read line; do
139
+    while read -r line; do
140
         echo -n "${line:0:1}" | tr '[:lower:]' '[:upper:]'
140
         echo -n "${line:0:1}" | tr '[:lower:]' '[:upper:]'
141
         echo "${line#?}"
141
         echo "${line#?}"
142
     done
142
     done
147
     # Add punctuation to each line on stdin
147
     # Add punctuation to each line on stdin
148
     #
148
     #
149
     local line      # every line
149
     local line      # every line
150
-    while read line; do
150
+    while read -r line; do
151
         case "${line}" in
151
         case "${line}" in
152
             [Ii]f*)     echo "${line},";;
152
             [Ii]f*)     echo "${line},";;
153
             '')         echo;;
153
             '')         echo;;
180
     local first     # first word of a line
180
     local first     # first word of a line
181
     local rest      # remainder of a line
181
     local rest      # remainder of a line
182
     local syl       # number of syllables in the first word
182
     local syl       # number of syllables in the first word
183
-    while read first rest; do
183
+    while read -r first rest; do
184
         case "$rest" in
184
         case "$rest" in
185
             *beer*)
185
             *beer*)
186
                 first=${first/zero/no}
186
                 first=${first/zero/no}