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

RE: Dynamically adding to $mailpath?



> Should this;
> 
>   typeset -a mailpath
>   for i in ~/mail/*.spool; do
>     set $mailpath[$#mailpath+1]="${i}?You have new mail in $(basename $i
> .spool).";
>   done
> 
> have worked? 

No; 

1. $mailpath[$#mailpath+1] is evaluated before even trying to execute
anyting so the above is the same as

set ="{i}..."

2. set foo[bar] is wrong for setting any variable anyway

3. you do not need basename in zsh, it does it internally.


I got around it by using $MAILPATH, but
> 
>   zsh: /home/hcksplat/mail/X.spool?You have new mail in X. not found
>   $
> 
> doesn't seem right to me. ZSH_VERSION=4.0.4, setopt gives nobeep,
> correct, noglobalrcs, histignoredups, histignorespace, interactive,
> monitor, shinstdin.
> 

mailpath=((${$(echo ~/mail/*.spool(N))//(#m)*/$MATCH?You have new mail in
${MATCH:r:t}}))

should work though. Unfortunately you still need one fork (echo) unless I
miss some obvious way to treat result of nested globbing as array.

-andrey



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