Add a POSIX solution without a subshell

dunatotatos
2016-09-18 18:50:50 +03:00
parent 2bfc5a9fa7
commit 3748ffe6d1

@@ -27,6 +27,17 @@ do
done < <(grep -v '^ *#' < file)
```
or without a subshell, with a pipe (more portable, but write a file on the filesystem):
```sh
mkfifo mypipe
while IFS= read -r line
do
echo "Line: $line"
done < mypipe
rm mypipe
```
### Rationale:
For loops by default (subject to `$IFS`) read word by word. Additionally, glob expansion will occur.