use upstream name for bash dependency
[log-quiet] / logmail
diff --git a/logmail b/logmail
index 4aad395591d9f123072ef545e7d25f5cce937d53..bece0ae8683ecd72818599f9a42dcb5d6e312200 100755 (executable)
--- a/logmail
+++ b/logmail
@@ -19,13 +19,17 @@ case $1 in
 usage: logmail CMD [ARGS...]
 
 Send mail in case of output or failure of CMD
+
+Emails to $MAILTO or if unset, $USER@localhost
 EOF
     exit 0
     ;;
 esac
 t=$(mktemp)
-if ! "$@" &>"$t" || [[ ! -s $t ]]; then
-  mail -s "$HOSTNAME: $*" $USER@localhost <"$t"
+code=0
+"$@" &>"$t" || code=$?
+if (( code )) || [[ -s $t ]]; then
+  mail -s "$HOSTNAME: code: $code cmd: $*" $mailto <"$t"
   rm "$t"
 fi
 exit 0