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

Re: Dynamically adding to $mailpath?



On 2002-12-19 at 11:22 +0000, Aidan Kehoe wrote:

>   for i in ~/mail/*.spool; do 
>     set $mailpath[$#mailpath+1]="${i}?You have new mail in $(basename $i .spool)."; 
>   done
> 
> have worked? I got around it by using $MAILPATH, but 

No, since you set a variable using its name without a $ beforehand.  I
have this problem too, when I've been writing too much Perl.

For some reason, the "set" there means that the array part isn't in
arithmetic context, in fact the rest is not evaluated properly, but is
instead treated as one string (or two, with s/=/ /) and put into ARGV.
Since "z" is at the end of the alphabet:
% print -l $@
mailpath[0+1]=/home/phil/Mail/Lists/zsh?You have new mail in zsh.
%

Lose the "set $" and it works for me, after changing to my set-up.  And
one optimisation, dropping the subshell ...

typeset -a mailpath
for i in ~/Mail/Lists/*(.); do
 mailpath[$#mailpath+1]="${i}?You have new mail in ${i:t}."
done

-- 
"We've got a patent on the conquering of a country through the use of force.
 We believe in world peace through extortionate license fees." -- Andy Forster



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