diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-06-08 09:26:01 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-06-08 09:26:01 +0000 |
commit | fcd7cd1cfa2ba286f4bf73da7a60116cd3912629 (patch) | |
tree | d2aa5a9369bf3af8841d3abde69f52bd483f5526 /Functions/Misc/checkmail | |
parent | b39cafaa22ad7efc2ac4b64a5eeac8f49bc80e00 (diff) | |
download | zsh-fcd7cd1cfa2ba286f4bf73da7a60116cd3912629.tar.gz zsh-fcd7cd1cfa2ba286f4bf73da7a60116cd3912629.tar.xz zsh-fcd7cd1cfa2ba286f4bf73da7a60116cd3912629.zip |
Initial revision
Diffstat (limited to 'Functions/Misc/checkmail')
-rw-r--r-- | Functions/Misc/checkmail | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Functions/Misc/checkmail b/Functions/Misc/checkmail new file mode 100644 index 000000000..9cc743db4 --- /dev/null +++ b/Functions/Misc/checkmail @@ -0,0 +1,26 @@ +#! /usr/local/bin/zsh +# +# This autoloadable function checks the folders specified as arguments +# for new mails. The arguments are interpeted in exactly the same way +# as the mailpath special zsh parameter (see zshparam(1)). +# +# If no arguments are given mailpath is used. If mailpath is empty, $MAIL +# is used and if that is also empty, /var/spool/mail/$LOGNAME is used. +# This function requires zsh-3.0.1 or newer. +# + +local file message + +for file in "${@:-${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" + fi + elif test -s "$file" -a -N "$file"; then # this also sets $_ to $file + print -r -- "${(e)message:-You have new mail.}" + fi +done |