-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
For bugs
- Rule Id (if any, e.g. SC1000): SC2120
- My shellcheck version (
shellcheck --versionor "online"): online - The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
For new checks and feature suggestions
- https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
- I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related
Here's a snippet or screenshot that shows the problem:
#!/usr/bin/env bash
clean_up() {
local code=$?
printf 'Cleaning up!\n'
if [[ -n "$1" ]]; then
printf 'Invoked due to error %d on line %d\n' "$code" "$1"
exit "$code"
fi
exit 0
}
trap 'clean_up $LINENO' ERR SIGINT SIGTERM SIGQUIT
if [[ -z "$INPUT" ]]; then
printf 'Missing input!\n'
clean_up
fi
# do somethingHere's what shellcheck currently says:
Line 3:
clean_up() {
^-- SC2120 (warning): clean_up references arguments, but none are ever passed.
Line 17:
clean_up
^-- SC2119 (info): Use clean_up "$@" if function's $1 should mean script's $1.
Here's what I wanted or expected to see:
No SC2120 error as trap 'clean_up $LINENO' ERR SIGINT SIGTERM SIGQUIT can call clean_up with an argument.
chreekat
Metadata
Metadata
Assignees
Labels
No labels