mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Add a POSIX solution without a subshell
11
SC2013.md
11
SC2013.md
@@ -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.
|
||||
|
Reference in New Issue
Block a user