mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Destroyed SC2131 (markdown)
24
SC2131.md
24
SC2131.md
@@ -1,24 +0,0 @@
|
|||||||
## This format string has 2 variables, but is passed 1 arguments.
|
|
||||||
|
|
||||||
### Problematic code:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
printf "Hello %s, welcome to %s.\n" "$USER"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Correct code:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
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 each time.
|
|
||||||
|
|
||||||
You should either remove the unused variables from the format string, or add enough arguments to fill them.
|
|
||||||
|
|
||||||
### Exceptions:
|
|
||||||
|
|
||||||
None.
|
|
Reference in New Issue
Block a user