Skip to content

Files

Latest commit

 

History

History
27 lines (16 loc) · 597 Bytes

SC2183.md

File metadata and controls

27 lines (16 loc) · 597 Bytes

Pattern: Mismatched printf arguments

Issue: -

Description

You're using a printf format string with more %s variables than arguments to fill them.

Example of incorrect code:

printf "Hello %s, welcome to %s.\n" "$USER"

The last %s will just become an empty string every time.

Either remove the unused variables from the format string, or add enough arguments to fill them.

Example of correct code:

printf "Hello %s, welcome to %s.\n" "$USER" "$HOSTNAME"

Further Reading