Pattern: Use of process substitution
Issue: -
Process substitution is a ksh and bash extension. It does not work in sh or dash scripts.
The easiest fix is to switch to a shell that does support process substitution, by changing the shebang to #!/bin/bash
or ksh
.
Example of incorrect code:
#!/bin/sh
while IFS= read -r n
do
sum=$((sum+n))
done < <(program)
Example of correct code:
#!/bin/bash
while IFS= read -r n
do
sum=$((sum+n))
done < <(program)
Alternatively, process substitution can often be replaced with temporary files:
#!/bin/sh
tmp="$(mktemp)"
program > "$tmp"
while IFS= read -r n
do
sum=$((sum+n))
done < "$tmp"
rm "$tmp"