mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Add normal pipes as a possible alternative
10
SC3001.md
10
SC3001.md
@@ -39,6 +39,16 @@ rm "$tmp"
|
||||
|
||||
If streaming is important, the temporary file can be a named pipe, and the producer or consumer can be run as a background job.
|
||||
|
||||
If the reading command accepts input from standard input, the process substitution can be replaced with a regular pipe:
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
program | while IFS= read -r n
|
||||
do
|
||||
sum=$((sum+n))
|
||||
done
|
||||
```
|
||||
|
||||
### Rationale:
|
||||
|
||||
Process substitution is a ksh and bash extension. It does not work in sh or dash scripts.
|
||||
|
Reference in New Issue
Block a user