* Re: functions/Misc/checkmail doesn't work when MAILPATH is a directory
[not found] <20060915174626.GA9429@localhost.localdomain>
@ 2006-09-15 18:07 ` Peter Stephenson
2006-09-15 18:18 ` arno.
0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 2006-09-15 18:07 UTC (permalink / raw)
To: Zsh users list
"arno." <arno.@no-log.org> 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 <pws@csr.com> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: functions/Misc/checkmail doesn't work when MAILPATH is a directory
2006-09-15 18:07 ` functions/Misc/checkmail doesn't work when MAILPATH is a directory Peter Stephenson
@ 2006-09-15 18:18 ` arno.
0 siblings, 0 replies; 2+ messages in thread
From: arno. @ 2006-09-15 18:18 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 234 bytes --]
Le Friday 15 September 2006, à 19:07:56PM +0100, Peter a écrit :
>
> That's a good thing to do, but probably it's safer to sanitize all the
> options... does the following patch work?
>
Yes, your patch works
thanks
arno
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-09-15 18:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20060915174626.GA9429@localhost.localdomain>
2006-09-15 18:07 ` functions/Misc/checkmail doesn't work when MAILPATH is a directory Peter Stephenson
2006-09-15 18:18 ` arno.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).