From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4650 invoked from network); 15 Sep 2006 17:46:51 -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.5 required=5.0 tests=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 17:46:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 87302 invoked from network); 15 Sep 2006 17:46:45 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Sep 2006 17:46:45 -0000 Received: (qmail 10236 invoked by alias); 15 Sep 2006 17:46:43 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22716 Received: (qmail 10226 invoked from network); 15 Sep 2006 17:46:42 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Sep 2006 17:46:42 -0000 Received: (qmail 87009 invoked from network); 15 Sep 2006 17:46:42 -0000 Received: from smtp5-g19.free.fr (212.27.42.35) by a.mx.sunsite.dk with SMTP; 15 Sep 2006 17:46:37 -0000 Received: from localhost (evr91-1-82-227-12-160.fbx.proxad.net [82.227.12.160]) by smtp5-g19.free.fr (Postfix) with ESMTP id 465DF275D3 for ; Fri, 15 Sep 2006 19:46:37 +0200 (CEST) Date: Fri, 15 Sep 2006 19:46:26 +0200 From: "arno." To: zsh-workers@sunsite.dk Subject: functions/Misc/checkmail doesn't work when MAILPATH is a directory Message-ID: <20060915174626.GA9429@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="T4sUOijqQbZv57TR" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) --T4sUOijqQbZv57TR Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, functions/Misc/checkmail is a function that is supposed to output a=20 message when new mail is detected (either with function arguments, or=20 else $MAILPATH, or else $MAIL, or else /var/spool/mail/$LOGNAME I use MAILPATH=3D~/Mail and have many files (mbox) in that directory. That function doesn't work. That is because=20 if [[ -d "$file" ]] then file=3D( "$file"/**/*(.ND) ) if (($#file)) then checkmail "${^file}\?$message" fi fi checkmail will be called with an array that contains all the files in=20 MAILPATH but=20 for file in "${@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}" will give a scalar. file will be a string containing all the files. So, test -s "$file" -a -N "$file" will be=20 test -s file1 file2 file3 -a -N file1 file2 file3, and will never succeed I found a way to solve this by splitting the function arguments : for file in "${(z)@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}" but I'm not sure if it is the better way. Another bug I found was : checkmail "${^file}\?$message" if message is "Hello", this gives checkmail file1 file2 file3?Hello By removing the double quotes, this works fine checkmail ${^file}\?$message gives checkmail file1?Hello file2?Hello file3?Hello Here is a patch containing fixes for the two problems arno Index: Functions/Misc/checkmail =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Functions/Misc/checkmail,v retrieving revision 1.4 diff -n -u -r1.4 checkmail --- Functions/Misc/checkmail 29 May 2001 17:54:39 -0000 1.4 +++ Functions/Misc/checkmail 15 Sep 2006 17:38:38 -0000 @@ -1,4 +1,4 @@ -#! /usr/local/bin/zsh +#! /usr/bin/zsh # # This autoloadable function checks the folders specified as arguments # for new mails. The arguments are interpreted in exactly the same way @@ -10,15 +10,16 @@ # =20 local file message +setopt noshwordsplit =20 -for file in "${@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}" +for file in "${(z)@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}" do message=3D"${${(M)file%%\?*}#\?}" file=3D"${file%%\?*}" if [[ -d "$file" ]] then file=3D( "$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.}" --T4sUOijqQbZv57TR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFCubyiH9aBScBsrMRAoJJAJ9XKiuYc3Gl6cj6hWjJKOogAN8fkgCgna68 Ujq0lnj0be5wVg+ktssIUNE= =n/iO -----END PGP SIGNATURE----- --T4sUOijqQbZv57TR--