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

Re: zsh-4.0.1-pre4 : manpath and MANPATH



Richard Curnow wrote:
> OK, next question ... what is a good way to delete all the environment
> variables apart from 'special' ones?

Actually, unsetting special variables should work --- I hope we're getting
there.  Anyway...

The simplest way I can think of is to use the parameter module.  The
associative array $parameters has keys which are parameter names and values
which are the types, which contains what you want to know.  (You can get
that type information for a parameter with ${(t)paramname}, but you have to
use e.g. typeset to generate a a list of parameters to test, so this method
is a bit easier.)  Something like:

zmodload -i zsh/parameter
for param in ${(k)parameters}; do
  type=${parameters[$param]}
  [[ $type != *export* || $type = *special* ]] && continue
  unset $param
done

Somebody may be able to think of a faster way.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



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