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

Add a directive for treating a command as an alias of another command #3060

Open thecaralice opened 1 month ago

thecaralice commented 1 month ago

For new checks and feature suggestions

In the example provided below, info essentially behaves like printf in terms of argument processing, so I would expect to have an option to say "info is basically printf with a different name" to shellcheck

Here's a snippet or screenshot that shows the problem:

#!/bin/sh

name="alice"

info() {
    printf '\x1b[2m'
    # shellcheck disable=SC2059 # intentional
    printf "$@"
    printf '\x1b[m'
}

info "hello $name"

Here's what shellcheck currently says:

No issues detected!

Here's what I wanted or expected to see:

Line 12:
info "hello $name"
     ^-- SC2059 (info): Don't use variables in the info format string. Use info '..%s..' "$foo".