`< <(cat file)` 和 `<file` 馈送循环的区别

Difference in `< <(cat file)` and `<file` feeding loop

我看到了以下在 bash 脚本中读取文件的示例:

while read IP; do
  ${IPTABLES} -I INPUT -s "${IP}" -j DROP
done < <(cat "${BLACKLIST}")

但我想改为执行以下操作:

while read IP; do
  ${IPTABLES} -I INPUT -s "${IP}" -j DROP
done <${BLACKLIST}

为什么要使用 < <(cat 而不是简单的 <?最正确的方法是什么?

第二条评论 this question gives good reason why using cat is bad but RoseHosting.com seems pretty reputable and they suggest the code above that uses cat. I'm thinking the < <(cat file) looks like a weird way to cover up a bad practice. (here's another place it was pointed out cat piping to a loop is bad)

这是一个useless use of cat。人们可能将它与 单个 文件一起使用的唯一合理原因是为了易读性(例如 cat file | while ...),但在这种情况下它只会变得更加复杂。