In the shell script, called the variable options. The script fails. If renamed, there is no error. Is this a reserved name? What does the error "attempt to assign a part of an associative array" mean?
This does not work:
function mcve() { options=''; echo 'ok'; } $ mcve mcve:1: options: attempt to set slice of associative array
And so - it works.
function mcve() { opts=''; echo 'ok'; } $ mcve ok
zsh 5.0.5 (x86_64-apple-darwin14.0)
UPD. According to man zshmisc
, this word is not reserved.
If you are using the command word, you can
disable -r
.
do done esac then elif else fi for case if while function repeat time until select coproc nocorrect foreach end ! [[ { }
UPD2.
Before the first function call with the string options='';
(which gives an error):
$ declare options options
After calling the function:
$declare options options=(autolist on printexitvalue off...<20 строк опций>)
And this syntax passes without errors.
function mcve() { declare options; options=''; echo ok; } $ zsh $ mcve ok