diff --git a/SC3001.md b/SC3001.md index cfb7008..132653f 100644 --- a/SC3001.md +++ b/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.