shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

SC2145 incorrectly errors on string and array concatenated seperately but wtihoout space.

Open baelish opened this issue 7 years ago • 1 comments

For bugs

  • Rule Id (if any, e.g. SC1000): SC2145
  • My shellcheck version (shellcheck --version or "online"): 0.6.0 (and online)
  • [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • [x] 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:

image image

#!/usr/bin/env bash
tagApiPaths=(
        blah
        blah
        blah
)
echo "DEBUG" $'tagApiPaths \n'"${tagApiPaths[@]}"

adding a space like so:

#!/usr/bin/env bash
tagApiPaths=(
        blah
        blah
        blah
)
echo "DEBUG" $'tagApiPaths \n' "${tagApiPaths[@]}"

makes the error message go away but it adds an undesirable space in front of the first entry of the array.

Here's what shellcheck currently says:

Argument mixes string and array. Use * or separate argument. [SC2145]

Here's what I wanted or expected to see:

Nothing, there is nothing wrong with the line.

baelish avatar Mar 07 '19 12:03 baelish

Sigh.... just doing what it says makes my issue go away ofcourse. Closing issue. i.e. echo "DEBUG" $'tagApiPaths \n'"${tagApiPaths[*]}" does what I want...

baelish avatar Mar 07 '19 12:03 baelish