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

problem/bug: array definition from command (backticks) [long]



With the following line in my ~/.zshrc, I specify the mailfolders that I
want zsh to watch for new mail:

mailpath=(`~/bin/printmailfolders-zsh.pl`)

The program ~/bin/printmailfolders-zsh.pl is a little Perl program that
outputs all the files (with some rudimentary filtering) in the directory
(I am assuming that the mail directory only contains mail folders):

--- BEGIN printmailfolders-zsh.pl
#!/usr/bin/perl -w
use strict;

my @MAILDIRS = ("$ENV{HOME}/Mail", "$ENV{HOME}/savenews");
my $folders;

foreach my $MAILDIR (@MAILDIRS) {

	opendir DIR, $MAILDIR;
	my @folders = grep {! /^\./ && -r $_ && -f _ && ! -d _ && -s _ && -T _} map {"$MAILDIR/$_"} readdir DIR;
	closedir DIR;

	foreach (@folders) {

	    (my $folder = $_) =~ s,^.*/([^/]+)$,$1,;
	    $folders .= qq/"$_?New mail in $folder."\\n/;

	}

}

print $folders;
--- END printmailfolders-zsh.pl

The output of the program is as follows:

"/fuse4/47/gt4556a/Mail/sent?New mail in sent."
"/fuse4/47/gt4556a/Mail/saved?New mail in saved."
"/fuse4/47/gt4556a/Mail/postponed?New mail in postponed."
"/fuse4/47/gt4556a/Mail/friends?New mail in friends."
"/fuse4/47/gt4556a/Mail/cs?New mail in cs."
"/fuse4/47/gt4556a/Mail/SPOOL?New mail in SPOOL."
"/fuse4/47/gt4556a/Mail/2answer?New mail in 2answer."
"/fuse4/47/gt4556a/Mail/me?New mail in me."
"/fuse4/47/gt4556a/Mail/SPAM?New mail in SPAM."
"/fuse4/47/gt4556a/Mail/family?New mail in family."
"/fuse4/47/gt4556a/Mail/stipendien?New mail in stipendien."
"/fuse4/47/gt4556a/Mail/elza?New mail in elza."
"/fuse4/47/gt4556a/Mail/spool?New mail in spool."
"/fuse4/47/gt4556a/Mail/projects?New mail in projects."
"/fuse4/47/gt4556a/Mail/wsf?New mail in wsf."
"/fuse4/47/gt4556a/Mail/books?New mail in books."
"/fuse4/47/gt4556a/Mail/perl6?New mail in perl6."
"/fuse4/47/gt4556a/Mail/perldoc?New mail in perldoc."
"/fuse4/47/gt4556a/Mail/ece?New mail in ece."
"/fuse4/47/gt4556a/Mail/uni?New mail in uni."
"/fuse4/47/gt4556a/Mail/mutt-dev?New mail in mutt-dev."
"/fuse4/47/gt4556a/Mail/misc?New mail in misc."
"/fuse4/47/gt4556a/Mail/vim?New mail in vim."
"/fuse4/47/gt4556a/Mail/flights?New mail in flights."
"/fuse4/47/gt4556a/Mail/soaplite?New mail in soaplite."
"/fuse4/47/gt4556a/Mail/ae?New mail in ae."
"/fuse4/47/gt4556a/Mail/dc?New mail in dc."
"/fuse4/47/gt4556a/Mail/vim-help?New mail in vim-help."
"/fuse4/47/gt4556a/Mail/einkauf?New mail in einkauf."
"/fuse4/47/gt4556a/Mail/da?New mail in da."
"/fuse4/47/gt4556a/Mail/sp?New mail in sp."
"/fuse4/47/gt4556a/Mail/sw?New mail in sw."
"/fuse4/47/gt4556a/Mail/phd?New mail in phd."
"/fuse4/47/gt4556a/Mail/kde-devel?New mail in kde-devel."
"/fuse4/47/gt4556a/Mail/swig?New mail in swig."
"/fuse4/47/gt4556a/Mail/perlqt?New mail in perlqt."
"/fuse4/47/gt4556a/Mail/ruby-cvs?New mail in ruby-cvs."
"/fuse4/47/gt4556a/Mail/ruby-talk?New mail in ruby-talk."
"/fuse4/47/gt4556a/Mail/ruby-de?New mail in ruby-de."
"/fuse4/47/gt4556a/Mail/fwp?New mail in fwp."
"/fuse4/47/gt4556a/savenews/comp.mail.mutt?New mail in comp.mail.mutt."
"/fuse4/47/gt4556a/savenews/comp.editors?New mail in comp.editors."

But this doesn't work as expected: The space in the descriptions ("New
mail in bla") is not recognized as such but it is interpreted as
separator of array elements:

acmey:~> echo $MAILPATH
"/fuse4/47/gt4556a/Mail/sent?New:mail:in:sent."
"/fuse4/47/gt4556a/Mail/saved?New:mail:in:saved."
"/fuse4/47/gt4556a/Mail/postponed?New:mail:in:postponed."
"/fuse4/47/gt4556a/Mail/friends?New:mail:in:friends."
"/fuse4/47/gt4556a/Mail/cs?New:mail:in:cs."
"/fuse4/47/gt4556a/Mail/SPOOL?New:mail:in:SPOOL."
"/fuse4/47/gt4556a/Mail/2answer?New:mail:in:2answer."
"/fuse4/47/gt4556a/Mail/me?New:mail:in:me."
"/fuse4/47/gt4556a/Mail/SPAM?New:mail:in:SPAM."
"/fuse4/47/gt4556a/Mail/family?New:mail:in:family."
"/fuse4/47/gt4556a/Mail/stipendien?New:mail:in:stipendien."
"/fuse4/47/gt4556a/Mail/elza?New:mail:in:elza."
"/fuse4/47/gt4556a/Mail/spool?New:mail:in:spool."
"/fuse4/47/gt4556a/Mail/projects?New:mail:in:projects."
"/fuse4/47/gt4556a/Mail/wsf?New:mail:in:wsf."
"/fuse4/47/gt4556a/Mail/books?New:mail:in:books."
"/fuse4/47/gt4556a/Mail/perl6?New:mail:in:perl6."
"/fuse4/47/gt4556a/Mail/perldoc?New:mail:in:perldoc."
"/fuse4/47/gt4556a/Mail/ece?New:mail:in:ece."
"/fuse4/47/gt4556a/Mail/uni?New:mail:in:uni."
"/fuse4/47/gt4556a/Mail/mutt-dev?New:mail:in:mutt-dev."
"/fuse4/47/gt4556a/Mail/misc?New:mail:in:misc."
"/fuse4/47/gt4556a/Mail/vim?New:mail:in:vim."
"/fuse4/47/gt4556a/Mail/flights?New:mail:in:flights."
"/fuse4/47/gt4556a/Mail/soaplite?New:mail:in:soaplite."
"/fuse4/47/gt4556a/Mail/ae?New:mail:in:ae."
"/fuse4/47/gt4556a/Mail/dc?New:mail:in:dc."
"/fuse4/47/gt4556a/Mail/vim-help?New:mail:in:vim-help."
"/fuse4/47/gt4556a/Mail/einkauf?New:mail:in:einkauf."
"/fuse4/47/gt4556a/Mail/da?New:mail:in:da."
"/fuse4/47/gt4556a/Mail/sp?New:mail:in:sp."
"/fuse4/47/gt4556a/Mail/sw?New:mail:in:sw."
"/fuse4/47/gt4556a/Mail/phd?New:mail:in:phd."
"/fuse4/47/gt4556a/Mail/kde-devel?New:mail:in:kde-devel."
"/fuse4/47/gt4556a/Mail/swig?New:mail:in:swig."
"/fuse4/47/gt4556a/Mail/perlqt?New:mail:in:perlqt."
"/fuse4/47/gt4556a/Mail/ruby-cvs?New:mail:in:ruby-cvs."
"/fuse4/47/gt4556a/Mail/ruby-talk?New:mail:in:ruby-talk."
"/fuse4/47/gt4556a/Mail/ruby-de?New:mail:in:ruby-de."
"/fuse4/47/gt4556a/Mail/fwp?New:mail:in:fwp."
"/fuse4/47/gt4556a/savenews/comp.mail.mutt?New:mail:in:comp.mail.mutt."
"/fuse4/47/gt4556a/savenews/comp.editors?New:mail:in:comp.editors."

($mailpath seems normal.) Therefore, when I get new mail, zsh totally
screws up and prints one default message for each of the folders.  D'oh.

However, when I take the output of the Perl program and directly take it
do define the mailpath array, it works out fine:

mailpath=(
"/fuse4/47/gt4556a/Mail/sent?New mail in sent."
"/fuse4/47/gt4556a/Mail/saved?New mail in saved."
"/fuse4/47/gt4556a/Mail/postponed?New mail in postponed."
"/fuse4/47/gt4556a/Mail/friends?New mail in friends."
"/fuse4/47/gt4556a/Mail/cs?New mail in cs."
"/fuse4/47/gt4556a/Mail/SPOOL?New mail in SPOOL."
"/fuse4/47/gt4556a/Mail/2answer?New mail in 2answer."
"/fuse4/47/gt4556a/Mail/me?New mail in me."
"/fuse4/47/gt4556a/Mail/SPAM?New mail in SPAM."
"/fuse4/47/gt4556a/Mail/family?New mail in family."
"/fuse4/47/gt4556a/Mail/stipendien?New mail in stipendien."
"/fuse4/47/gt4556a/Mail/elza?New mail in elza."
"/fuse4/47/gt4556a/Mail/spool?New mail in spool."
"/fuse4/47/gt4556a/Mail/projects?New mail in projects."
"/fuse4/47/gt4556a/Mail/wsf?New mail in wsf."
"/fuse4/47/gt4556a/Mail/books?New mail in books."
"/fuse4/47/gt4556a/Mail/perl6?New mail in perl6."
"/fuse4/47/gt4556a/Mail/perldoc?New mail in perldoc."
"/fuse4/47/gt4556a/Mail/ece?New mail in ece."
"/fuse4/47/gt4556a/Mail/uni?New mail in uni."
"/fuse4/47/gt4556a/Mail/mutt-dev?New mail in mutt-dev."
"/fuse4/47/gt4556a/Mail/misc?New mail in misc."
"/fuse4/47/gt4556a/Mail/vim?New mail in vim."
"/fuse4/47/gt4556a/Mail/flights?New mail in flights."
"/fuse4/47/gt4556a/Mail/soaplite?New mail in soaplite."
"/fuse4/47/gt4556a/Mail/ae?New mail in ae."
"/fuse4/47/gt4556a/Mail/dc?New mail in dc."
"/fuse4/47/gt4556a/Mail/vim-help?New mail in vim-help."
"/fuse4/47/gt4556a/Mail/einkauf?New mail in einkauf."
"/fuse4/47/gt4556a/Mail/da?New mail in da."
"/fuse4/47/gt4556a/Mail/sp?New mail in sp."
"/fuse4/47/gt4556a/Mail/sw?New mail in sw."
"/fuse4/47/gt4556a/Mail/phd?New mail in phd."
"/fuse4/47/gt4556a/Mail/kde-devel?New mail in kde-devel."
"/fuse4/47/gt4556a/Mail/swig?New mail in swig."
"/fuse4/47/gt4556a/Mail/perlqt?New mail in perlqt."
"/fuse4/47/gt4556a/Mail/ruby-cvs?New mail in ruby-cvs."
"/fuse4/47/gt4556a/Mail/ruby-talk?New mail in ruby-talk."
"/fuse4/47/gt4556a/Mail/ruby-de?New mail in ruby-de."
"/fuse4/47/gt4556a/Mail/fwp?New mail in fwp."
"/fuse4/47/gt4556a/savenews/comp.mail.mutt?New mail in comp.mail.mutt."
"/fuse4/47/gt4556a/savenews/comp.editors?New mail in comp.editors."

)

gives:

acmey:~> echo $MAILPATH

/fuse4/47/gt4556a/Mail/sent?New mail in
sent.:/fuse4/47/gt4556a/Mail/saved?New mail in
saved.:/fuse4/47/gt4556a/Mail/postponed?New mail in
postponed.:/fuse4/47/gt4556a/Mail/friends?New mail in
friends.:/fuse4/47/gt4556a/Mail/cs?New mail in
cs.:/fuse4/47/gt4556a/Mail/SPOOL?New mail in
SPOOL.:/fuse4/47/gt4556a/Mail/2answer?New mail in
2answer.:/fuse4/47/gt4556a/Mail/me?New mail in
me.:/fuse4/47/gt4556a/Mail/SPAM?New mail in
SPAM.:/fuse4/47/gt4556a/Mail/family?New mail in
family.:/fuse4/47/gt4556a/Mail/stipendien?New mail in
stipendien.:/fuse4/47/gt4556a/Mail/elza?New mail in
elza.:/fuse4/47/gt4556a/Mail/spool?New mail in
spool.:/fuse4/47/gt4556a/Mail/projects?New mail in
projects.:/fuse4/47/gt4556a/Mail/wsf?New mail in
wsf.:/fuse4/47/gt4556a/Mail/books?New mail in
books.:/fuse4/47/gt4556a/Mail/perl6?New mail in
perl6.:/fuse4/47/gt4556a/Mail/perldoc?New mail in
perldoc.:/fuse4/47/gt4556a/Mail/ece?New mail in
ece.:/fuse4/47/gt4556a/Mail/uni?New mail in
uni.:/fuse4/47/gt4556a/Mail/mutt-dev?New mail in
mutt-dev.:/fuse4/47/gt4556a/Mail/misc?New mail in
misc.:/fuse4/47/gt4556a/Mail/vim?New mail in
vim.:/fuse4/47/gt4556a/Mail/flights?New mail in
flights.:/fuse4/47/gt4556a/Mail/soaplite?New mail in
soaplite.:/fuse4/47/gt4556a/Mail/ae?New mail in
ae.:/fuse4/47/gt4556a/Mail/dc?New mail in
dc.:/fuse4/47/gt4556a/Mail/vim-help?New mail in
vim-help.:/fuse4/47/gt4556a/Mail/einkauf?New mail in
einkauf.:/fuse4/47/gt4556a/Mail/da?New mail in
da.:/fuse4/47/gt4556a/Mail/sp?New mail in
sp.:/fuse4/47/gt4556a/Mail/sw?New mail in
sw.:/fuse4/47/gt4556a/Mail/phd?New mail in
phd.:/fuse4/47/gt4556a/Mail/kde-devel?New mail in
kde-devel.:/fuse4/47/gt4556a/Mail/swig?New mail in
swig.:/fuse4/47/gt4556a/Mail/perlqt?New mail in
perlqt.:/fuse4/47/gt4556a/Mail/ruby-cvs?New mail in
ruby-cvs.:/fuse4/47/gt4556a/Mail/ruby-talk?New mail in
ruby-talk.:/fuse4/47/gt4556a/Mail/ruby-de?New mail in
ruby-de.:/fuse4/47/gt4556a/Mail/fwp?New mail in
fwp.:/fuse4/47/gt4556a/savenews/comp.mail.mutt?New mail in
comp.mail.mutt.:/fuse4/47/gt4556a/savenews/comp.editors?New mail in
comp.editors.

(The line wrappings are from MUA formatting.)

I already tried various other quoting and array definition styles (w/ or
w/o the \n, ' instead of "), but without success.

Any hint is greatly appreciated.

Jörg

P.s.:

* I am using zsh 3.1.6 (yeah, I know it's old but I can't upgrade right
now).
* my ~/.zshrc:

alias -g M='| more'
alias -g L='| less'
alias -g G='| grep'
PROMPT='%m:%B%~%b> '
RPROMPT="%(2L.[$SHLVL].)[%B%*%b]"
setopt correctall
setopt no_beep
setopt auto_cd
HISTSIZE=200
HISTFILE=~/.zsh_history
SAVEHIST=200
bindkey -e
#watch=(notme)
LOGCHECK=60
WATCHFMT='%n %a %l from %m.'

. ~/.alias
export PATH=$PATH:/tnt1/38/gtwreck/bin:$HOME/bin:$HOME/local/bin:$HOME/nmh/bin:$HOME/nmh/lib

PAGER=less
PERL5LIB=~/perl
NNTPSERVER=news.gatech.edu
VIM=/usr/local/share/vim/vim57/

mailpath=(
"/fuse4/47/gt4556a/Mail/sent?New mail in sent."
"/fuse4/47/gt4556a/Mail/saved?New mail in saved."
"/fuse4/47/gt4556a/Mail/postponed?New mail in postponed."
"/fuse4/47/gt4556a/Mail/friends?New mail in friends."
"/fuse4/47/gt4556a/Mail/cs?New mail in cs."
"/fuse4/47/gt4556a/Mail/SPOOL?New mail in SPOOL."
"/fuse4/47/gt4556a/Mail/2answer?New mail in 2answer."
"/fuse4/47/gt4556a/Mail/me?New mail in me."
"/fuse4/47/gt4556a/Mail/SPAM?New mail in SPAM."
"/fuse4/47/gt4556a/Mail/family?New mail in family."
"/fuse4/47/gt4556a/Mail/stipendien?New mail in stipendien."
"/fuse4/47/gt4556a/Mail/elza?New mail in elza."
"/fuse4/47/gt4556a/Mail/spool?New mail in spool."
"/fuse4/47/gt4556a/Mail/projects?New mail in projects."
"/fuse4/47/gt4556a/Mail/wsf?New mail in wsf."
"/fuse4/47/gt4556a/Mail/books?New mail in books."
"/fuse4/47/gt4556a/Mail/perl6?New mail in perl6."
"/fuse4/47/gt4556a/Mail/perldoc?New mail in perldoc."
"/fuse4/47/gt4556a/Mail/ece?New mail in ece."
"/fuse4/47/gt4556a/Mail/uni?New mail in uni."
"/fuse4/47/gt4556a/Mail/mutt-dev?New mail in mutt-dev."
"/fuse4/47/gt4556a/Mail/misc?New mail in misc."
"/fuse4/47/gt4556a/Mail/vim?New mail in vim."
"/fuse4/47/gt4556a/Mail/flights?New mail in flights."
"/fuse4/47/gt4556a/Mail/soaplite?New mail in soaplite."
"/fuse4/47/gt4556a/Mail/ae?New mail in ae."
"/fuse4/47/gt4556a/Mail/dc?New mail in dc."
"/fuse4/47/gt4556a/Mail/vim-help?New mail in vim-help."
"/fuse4/47/gt4556a/Mail/einkauf?New mail in einkauf."
"/fuse4/47/gt4556a/Mail/da?New mail in da."
"/fuse4/47/gt4556a/Mail/sp?New mail in sp."
"/fuse4/47/gt4556a/Mail/sw?New mail in sw."
"/fuse4/47/gt4556a/Mail/phd?New mail in phd."
"/fuse4/47/gt4556a/Mail/kde-devel?New mail in kde-devel."
"/fuse4/47/gt4556a/Mail/swig?New mail in swig."
"/fuse4/47/gt4556a/Mail/perlqt?New mail in perlqt."
"/fuse4/47/gt4556a/Mail/ruby-cvs?New mail in ruby-cvs."
"/fuse4/47/gt4556a/Mail/ruby-talk?New mail in ruby-talk."
"/fuse4/47/gt4556a/Mail/ruby-de?New mail in ruby-de."
"/fuse4/47/gt4556a/Mail/fwp?New mail in fwp."
"/fuse4/47/gt4556a/savenews/comp.mail.mutt?New mail in comp.mail.mutt."
"/fuse4/47/gt4556a/savenews/comp.editors?New mail in comp.editors."

)



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