#!/usr/bin/env tclsh8.5 #Checks if there is a new mail in Maildir folders # # Helper methods # #Gets maildir directory proc get_maildir {} { global env if [info exists env(MAILDIR)] { return $env(MAILDIR) } return $env(HOME)/Maildir } #Return "s" when amount needs a plural proc s {amount} { if {$amount >= 2} {return "s"} } # # Procedural code # #Checks if Maildir exists if [file exists [set maildir [get_maildir]]] { #Yes, check new mails set nb [llength [glob -nocomplain -directory $maildir/new *]] if {$nb > 0} { puts "" puts "*** You have $nb new mail[s $nb]" puts "" } } { #No, ask to create it puts "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" puts " You don't have setup your mail delivery." puts "" puts " Please run the following command:" puts " /var/qmail/bin/maildirmake $maildir" puts "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" }