Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 2 revisions

Use done < <(cmd) to redirect from process substitution (currently missing one <).

Problematic code:

sum=0
while IFS="" read -r n
do
  (( sum += n ))
done <(file) 

Correct code:

sum=0
while IFS="" read -r n
do
  (( sum += n ))
done < <(file) 

Rationale:

ShellCheck found a done keyword followed by a process substitution, e.g. done <(cmd).

The intention was most likely to redirect from this process substitution, in which case you will need one extra <: done < <(cmd).

This is because <(cmd) expands to a filename (e.g. /dev/fd/63), and you need a < to redirect from filenames.

Exceptions:

None

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature guerraart8 to find a specific , or see Checks.

Clone this wiki locally