Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[BUG] Tied parameters not restored correctly after pre-command re-assignment



Daniel's recent message to zsh-users got me experimenting with the use of tied
parameters in 'pre-command' re-assignments (i.e., the `foo=bar baz` form of
command).

I found that, in 5.4.1 and 5.4.2-dev, tied parameters are not restored correctly
to their previous values if re-assigned in this way after calling a shell
function or built-in:

  % typeset -T SCA arr
  % arr=( a b )
  % arr=( b c ) typeset -p SCA
  typeset SCA=b:c
  % typeset -p SCA
  typeset: no such variable: SCA

(It works the other way around too — with `SCA=b:c ...` it will unset arr.)

It seems that the restoration process simply doesn't concern itself with tied
parameters. It unsets the other parameter, but then there's nothing there to set
it back. I wasn't successful in trying to figure out exactly where it could be
fixed, but i see at least that the reason it unsets the other parameter is the
call to unsetparam_pm() in restore_params().

This doesn't happen when calling external commands, since the restoration isn't
relevant there. However, i also don't get the behaviour that i expect (which is
the scalar being passed down through the environment):

  % typeset -T SCA arr
  % arr=( a b )
  % arr=( b c ) zsh -fc 'print -r -- ${SCA:--}'
  -
  % typeset -p SCA
  typeset SCA=a:b

I guess that's probably a separate thing though.

Anyway, kind of esoteric, but idk, seems like misbehaviour.

dana



Messages sorted by: Reverse Date, Date, Thread, Author