In bind_comp_words, the readonly attribute is unconditionally removed from
COMP_WORDS, even if that variable is a nameref.  This allows unsetting the
readonly attribute on any arbitrary variable.

    v = find_variable ("COMP_WORDS");
    if (v == 0)
      v = make_new_array_variable ("COMP_WORDS");
    if (readonly_p (v))
      VUNSETATTR (v, att_readonly);

For example:

    $ readonly var=foo
    $ declare -n COMP_WORDS=var
    $ f() { :; }
    $ compgen -F f .
    bash: compgen: warning: -F option may not work as you expect
    $ declare -p var
    declare -a var=([0]="foo")

I'm not sure why shooting yourself in the foot by making COMP_WORDS
readonly should be forbidden, since the readonly attribute is not removed
from any of the other COMP_* variables.

Reply via email to