From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13423 invoked from network); 15 Sep 2006 18:08:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 Sep 2006 18:08:19 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 29432 invoked from network); 15 Sep 2006 18:08:12 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Sep 2006 18:08:12 -0000 Received: (qmail 18590 invoked by alias); 15 Sep 2006 18:08:03 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10720 Received: (qmail 18579 invoked from network); 15 Sep 2006 18:08:01 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Sep 2006 18:08:01 -0000 Received: (qmail 28200 invoked from network); 15 Sep 2006 18:08:01 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 15 Sep 2006 18:07:59 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly07c.srv.mailcontrol.com (MailControl) with ESMTP id k8FI7pbg007485 for ; Fri, 15 Sep 2006 19:07:57 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Fri, 15 Sep 2006 19:07:56 +0100 Date: Fri, 15 Sep 2006 19:07:56 +0100 From: Peter Stephenson To: Zsh users list Subject: Re: functions/Misc/checkmail doesn't work when MAILPATH is a directory Message-Id: <20060915190756.832515e8.pws@csr.com> In-Reply-To: <20060915174626.GA9429@localhost.localdomain> References: <20060915174626.GA9429@localhost.localdomain> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.2.6 (GTK+ 2.6.7; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 Sep 2006 18:07:56.0636 (UTC) FILETIME=[DEFB31C0:01C6D8F1] X-Scanned-By: MailControl A-07-04-01 (www.mailcontrol.com) on 10.67.0.117 "arno." wrote: > Hi, > functions/Misc/checkmail is a function that is supposed to output a > message when new mail is detected (either with function arguments, or > else $MAILPATH, or else $MAIL, or else /var/spool/mail/$LOGNAME > > I use MAILPATH=~/Mail and have many files (mbox) in that directory. > > That function doesn't work. That is because > > if [[ -d "$file" ]] then > file=( "$file"/**/*(.ND) ) > if (($#file)) then > checkmail "${^file}\?$message" > fi > fi > > checkmail will be called with an array that contains all the files in > MAILPATH > but > > for file in "${@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}" > > will give a scalar. Not if $@ or $mailpath is an array to begin with. I think the problem is that in your case $@ wasn't, because of the other bug: > checkmail "${^file}\?$message" > > if message is "Hello", this gives > > checkmail file1 file2 file3?Hello This was passing a single argument because of the double quotes. So I think fixing this should be enough. > +setopt noshwordsplit That's a good thing to do, but probably it's safer to sanitize all the options... does the following patch work? Index: Functions/Misc/checkmail =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Misc/checkmail,v retrieving revision 1.4 diff -u -r1.4 checkmail --- Functions/Misc/checkmail 29 May 2001 17:54:39 -0000 1.4 +++ Functions/Misc/checkmail 15 Sep 2006 18:06:18 -0000 @@ -9,6 +9,7 @@ # This function requires zsh-3.0.1 or newer. # +emulate -L zsh local file message for file in "${@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}" @@ -18,7 +19,7 @@ if [[ -d "$file" ]] then file=( "$file"/**/*(.ND) ) if (($#file)) then - checkmail "${^file}\?$message" + checkmail ${^file}\?$message fi elif test -s "$file" -a -N "$file"; then # this also sets $_ to $file print -r -- "${(e)message:-You have new mail.}" -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php