This format string has 2 variables, but is passed 1 argument.
Problematic code:
printf "Hello %s, welcome to %s.\n" "$USER"
Correct code:
printf "Hello %s, welcome to %s.\n" "$USER" "$HOSTNAME"
Rationale:
ShellCheck has noticed that you're using a printf
format string with more %s
variables than arguments to fill them.
In the problematic example case, 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.
Exceptions:
When using the Ksh/Bash %T
timestamp extension, such as printf 'The time is %(%H:%M)T\n'
, an argument of -1
and no argument are both taken to mean the current time. In these cases, consider specifying -1
explicitly.
-
Installation
-
Usage
-
Integrating and extending
Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.
<--- This is a global footer, please don't edit it. --->