Skip to content

Files

Latest commit

 

History

History
39 lines (25 loc) · 1009 Bytes

SC2217.md

File metadata and controls

39 lines (25 loc) · 1009 Bytes

Pattern: Redirecting to command that does not read from stdin

Issue: -

Description

You are redirecting to one of several commands that don't read from stdin.

This may happen when:

  • Confusing one command for another, e.g. using echo where cat was intended.
  • Incorrectly quoting angle brackets, e.g. using echo <p>Hello which tries to read from a file p.
  • Missing xargs, e.g. mv -t dir < files instead of xargs mv -t dir < files (or more safely, tr '\n' '\0' < files | xargs -0 mv -t dir), because stdin should be passed as parameters.

Check your logic, and rewrite the command so data is passed correctly.

Example of incorrect code:

echo << eof
  Hello World
eof

Example of correct code:

cat << eof
  Hello World
eof

Exceptions

If you've overridden a command to return output, you can either rename it to make this obvious, or ignore this message.

Further Reading