mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Add a note about grep being a placeholder; I've referenced this page for looping through pipes and files; years of my code uses this placeholder!!1
@@ -39,6 +39,15 @@ done < mypipe
|
||||
rm mypipe
|
||||
```
|
||||
|
||||
NOTE: `grep -v '^ *#'` is a placeholder example and not needed. To just loop through a file:
|
||||
```sh
|
||||
while IFS= read -r line
|
||||
do
|
||||
echo "Line: $line"
|
||||
done << file
|
||||
# or: done <<< "$variable"
|
||||
```
|
||||
|
||||
### Rationale:
|
||||
|
||||
For loops by default (subject to `$IFS`) read word by word. Additionally, glob expansion will occur.
|
||||
|
Reference in New Issue
Block a user