mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
@@ -12,7 +12,7 @@ done
|
|||||||
### Correct code:
|
### Correct code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
grep -v '^ *#' < file | while IFS= read -r line
|
grep -v '^ *#' file | while IFS= read -r line
|
||||||
do
|
do
|
||||||
echo "Line: $line"
|
echo "Line: $line"
|
||||||
done
|
done
|
||||||
@@ -24,14 +24,14 @@ or without a subshell (bash, zsh, ksh):
|
|||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do
|
do
|
||||||
echo "Line: $line"
|
echo "Line: $line"
|
||||||
done < <(grep -v '^ *#' < file)
|
done < <(grep -v '^ *#' file)
|
||||||
```
|
```
|
||||||
|
|
||||||
or without a subshell, with a pipe (more portable, but write a file on the filesystem):
|
or without a subshell, with a pipe (more portable, but write a file on the filesystem):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkfifo mypipe
|
mkfifo mypipe
|
||||||
grep -v '^ *#' < file > mypipe &
|
grep -v '^ *#' file > mypipe &
|
||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do
|
do
|
||||||
echo "Line: $line"
|
echo "Line: $line"
|
||||||
|
Reference in New Issue
Block a user