Skip to content

false postive SC2329 #3385

@dotysan

Description

@dotysan

For bugs

  • Rule Id (if any, e.g. SC1000): SC2329
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

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

#! /usr/bin/env bash
#
XTRACE=yep

main() {
    echo "hello:" "$@"
    return 1
}

if [[ "${XTRACE:-}" ]]
then
    PS4func() {
        printf "%b" "+${BASH_LINENO[0]}: "
          
    }
    PS4='\r$(PS4func)'
    set -o xtrace
fi

main "$@"
exit $?

Here's what shellcheck currently says:

Line 12	SC2329: This function is never invoked. Check usage (or ignored if invoked indirectly).

Here's what I wanted or expected to see:

That function is evoked and the script runs fine.

The exit $? on the last line seems to confuse SC2329.

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