Closed
Description
For bugs
- Rule Id: 1072
- Version: local 0.4.6 / also occurs online
- I tried on shellcheck.net and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#! /usr/bin/env bash
if [[ "$1" =~ [0-9]+ ]]
then
echo "$1"
# shellcheck disable=1001
elif [[ "$1" =~ [^0-9] ]]
then
echo "$2"
fi
Here's what shellcheck currently says:
Line 3:
if [[ "$1" =~ [0-9]+ ]]
^-- SC1009: The mentioned parser error was in this if expression.
Line 4:
then
^-- SC1073: Couldn't parse this then clause.
Line 7:
elif [[ "$1" =~ [^0-9] ]]
^-- SC1072: Unexpected keyword/token. Fix any mentioned problems and try again.
Here's what I wanted or expected to see:
No error exists in that code. The false positive does not occur if the disable
directive is missing or at the block level (outside the if
or a function block).
Metadata
Metadata
Assignees
Labels
No labels