koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.48k stars 1.78k forks source link

Error 2276 for Valid Zsh Assoc Array Assignment #3087

Closed wdeshazer closed 1 day ago

wdeshazer commented 1 day ago

For bugs

For new checks and feature suggestions

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

typeset -xgA ම

ම=( [ZSYS]=Something )
ම+=( [ZUSER]=Something\ Else )

Here's what shellcheck currently says:

Line 1  SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
Line 3  SC2276: This is interpreted as a command name containing '='. Bad assignment or comparison?
Line 3  SC1036: '(' is invalid here. Did you forget to escape it?
Line 3  SC1088: Parsing stopped here. Invalid use of parentheses?

Here's what I wanted or expected to see:

1) Assignment of an associative array or an array can be done post declaration. 2) The '+=' syntax with additional key-value's is valid syntax. https://zsh.sourceforge.io/Guide/zshguide05.html#5.4.2

Here is the relevant excerpt from the docs. Chap 15.2

15 Parameters

image

Let me know if you need anything else.

brother commented 1 day ago

zsh is not among the supported shell dialects (sh, bash, dash, ksh, busybox), closing. See #809.