-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
For bugs with existing features
- Rule Id: SC3057
- My shellcheck version (
shellcheck --versionor "online"): 0.10.0 - The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC3057)
- I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#! /bin/sh
cat << __LDIF__
dn: ${dn?}
changetype: modify${cn:+
replace: cn
cn: ${cn}
-}${uid:+
replace: uid
uid: ${uid}
-}
__LDIF__Here's what shellcheck currently says:
[Line 4:](javascript:setPosition(4, 19))
changetype: modify${cn:+
^-- [SC3057](https://www.shellcheck.net/wiki/SC3057) (warning): In POSIX sh, string indexing is undefined.
[Line 7:](javascript:setPosition(7, 3))
-}${uid:+
^-- [SC3057](https://www.shellcheck.net/wiki/SC3057) (warning): In POSIX sh, string indexing is undefined.
Here's what I wanted or expected to see:
Nothing. The code does not use string indexing.
More info
src/ShellCheck/Checks/ShellSupport.hs has simpleExpansions which makes a regular expression ^[_0-9a-zA-Z*@]+:[^-=?+] which can match not only in the beginning of a dollar brace expression but also in the beginning of lines within the dollar brace expression. It thus gives false positives for cn: , replace: and uid: even though those are not variable expressions at all.
Metadata
Metadata
Assignees
Labels
No labels