koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.45k stars 1.78k forks source link

Wrong format string variables count #3001

Open Rammy61 opened 5 months ago

Rammy61 commented 5 months ago

For bugs

Here's what shellcheck currently says:

printf '\r%s%*s' "$msg_" "$(( $( tput cols ) -${#msg_} ))"
       ^-------^ SC2183 (warning): This format string has 3 variables, but is passed 2 arguments.

printf '%*s' $(tput cols) | tr ' ' "${ch_}"
       ^---^ SC2183 (warning): This format string has 2 variables, but is passed 1 arguments.
             ^----------^ SC2046 (warning): Quote this to prevent word splitting.

Here's what I wanted or expected to see:

printf '\r%s%*s' "$msg_" "$(( $( tput cols ) -${#msg_} ))"
       ^-------^ SC2183 (warning): This format string has 2 variables, but is passed 2 arguments.

printf '%*s' $(tput cols) | tr ' ' "${ch_}"
       ^---^ SC2183 (warning): This format string has 1 variables, but is passed 1 arguments.
             ^----------^ SC2046 (warning): Quote this to prevent word splitting.