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

typeset -U within a function



>From either zsh-4.0.4 or from the latest CVS sources, when I create a
function like this:

function bar {
  typeset -U PATH
  PATH=/xxx:/yyy
}

and then run it, PATH is unchanged:

  zion% /usr/local/zsh-4.0.4/bin/zsh -f
  zion% function bar {
  function> typeset -U PATH
  function> PATH=/xxx:/yyy
  function> }
  zion% echo $PATH
  /home/acs/bin:/usr/local/bin:/usr/X11R6/bin:/bin:/usr/bin:/etc
  zion% bar
  zion% echo $PATH
  /home/acs/bin:/usr/local/bin:/usr/X11R6/bin:/bin:/usr/bin:/etc

If I remove the 'typeset -U PATH' line (even if PATH already had been
'typeset -U' before entering the function), the value of PATH is
changed by the function bar:

  zion% function bar {
  function> PATH=/xxx:/yyy
  function> }
  zion% echo $PATH
  /home/acs/bin:/usr/local/bin:/usr/X11R6/bin:/bin:/usr/bin:/etc
  zion% bar
  zion% echo $PATH
  /xxx:/yyy


  - vin



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