Skip to content

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

@magistau

Description

@magistau

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions