#!/bin/bash
#
# Author: Pablo Olmos de Aguilera C. pablo at glatelier dot org
#
# Little wrapper to prevent xmessage to pop if errors are thrown when
# (re)compiling xmonad. Of course this assumes that you should recompile it from
# the command line.
#
# Just make sure your $PATH is correctly set, before the original xmessage to
# this code run.
#
# Acknowledgements:
# * Brandon Allbery for the suggestion (http://permalink.gmane.org/gmane.comp.lang.haskell.xmonad/12794)
# * StackOverflow (once again...) for the ideas about how to know if "string contains":
# http://stackoverflow.com/questions/229551/string-contains-in-bash

# alternative using regex
if [[ "$3" =~ .*rror\ detected\ while\ loading\ xmonad\ configuration\ file:\
.*xmonad/xmonad.hs.* ]]; then
# another alternative using wildcards
#if [[ "$3" == *.xmonad/xmonad.hs* ]]
  exit 0
fi

/usr/bin/xmessage "$@"