You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionfoo[foo] { # "function" must be followed by a nameecho foo
}
bar[bar]() { # "a[b]" must be followed by =echo bar
}
run=(foo[foo] bar[bar]) # "[x]" must be followed by =${run[0]}${run[1]}
The text was updated successfully, but these errors were encountered:
foo[foo] and bar[bar] are just func names there, right? Out of curiosity, why would you use names that look like array indexing expressions? :)
I've personally never come across this in practice. If Bash supports it, we probably should support it as well, although it's worth noting that POSIX shell defines names (like function names) as simply:
In the shell command language, a word consisting solely of underscores, digits, and alphabetics from the portable character set. The first character of a name is not a digit.
Meaning that such func names are not valid POSIX Shell.
man bash, instead, says:
When in posix mode, fname must be a valid shell name and may not be the name of one of the POSIX special builtins. In default mode, a function name can be any unquoted shell word that does not contain $.
Pretty bonkers design decision from Bash if you ask me!
mvdan
changed the title
declare func with associative array
syntax: bash allows more characters in function names
Jun 25, 2023
The text was updated successfully, but these errors were encountered: