* functions/Misc/checkmail doesn't work when MAILPATH is a directory
@ 2006-09-15 17:46 arno.
0 siblings, 0 replies; only message in thread
From: arno. @ 2006-09-15 17:46 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]
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. file will be a string containing all the files.
So, test -s "$file" -a -N "$file" will be
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
===================================================================
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 @@
#
local file message
+setopt noshwordsplit
-for file in "${@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}"
+for file in "${(z)@:-${mailpath[@]:-${MAIL:-/var/spool/mail/$LOGNAME}}}"
do
message="${${(M)file%%\?*}#\?}"
file="${file%%\?*}"
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.}"
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-09-15 17:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-15 17:46 functions/Misc/checkmail doesn't work when MAILPATH is a directory 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).