about summary refs log tree commit diff
path: root/Functions/Misc/checkmail
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 13:04:04 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 13:04:04 +0000
commit3d7263ff67534b5d533c1d78eca8d648b72bca93 (patch)
treed7c3f8d1fbaf58d52b092ef241dc37db974c370d /Functions/Misc/checkmail
parentc6686513ef7eb29cbe4ed4cc27076d13b2e02ab5 (diff)
downloadzsh-3d7263ff67534b5d533c1d78eca8d648b72bca93.tar.gz
zsh-3d7263ff67534b5d533c1d78eca8d648b72bca93.tar.xz
zsh-3d7263ff67534b5d533c1d78eca8d648b72bca93.zip
after-move cleanup
Diffstat (limited to 'Functions/Misc/checkmail')
-rw-r--r--Functions/Misc/checkmail26
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