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

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



On Fri, Dec 8, 2017 at 2:51 PM, dana <dana@xxxxxxx> wrote:
>
> 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

Several things:  One, there's no implication that assigning to the
array part of a tied variable will have any effect on the environment
value of the scalar part unless you've explicitly exported the scalar.
  Two, exporting arrays is unsupported / undefined behavior, so using
an array assignment as a command prefix is only sensible in contexts
where all the execution takes place within the current shell (except
see also item one).  Three, if POSIX_BUILTINS is set there are
different rules for how prefix assignments are handled for certain
builtins vs. other cases, so you can't generalize from any particular
experiment.

% which printenv
/usr/bin/printenv
% typeset -xT ABC abc
% abc=(a b c) printenv ABC
a:b:c
% typeset -p ABC
export ABC=''
% typeset -T CBA cba
% cba=(c b a) printenv CBA
%


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

This works correctly if POSIX_BUILTINS is set, so I would guess it has
some relation to the thread on zsh-workers about "local -r path".



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