aboutsummaryrefslogtreecommitdiff
path: root/bin/with-email
diff options
context:
space:
mode:
Diffstat (limited to 'bin/with-email')
-rwxr-xr-xbin/with-email14
1 files changed, 3 insertions, 11 deletions
diff --git a/bin/with-email b/bin/with-email
index dc2a022..7df101a 100755
--- a/bin/with-email
+++ b/bin/with-email
@@ -69,15 +69,7 @@ while getopts 's:h' flag; do
done
shift $((OPTIND - 1))
-assert_arg() {
- if [ -z "$1" ]; then
- printf 'Missing %s\n\n' "$2" >&2
- usage >&2
- exit 2
- fi
-}
-
-assert_arg "${1:-}" 'COMMAND...'
+eval "$(assert-arg "${1:-}" 'COMMAND...')"
now() {
date '+%Y-%m-%dT%H:%M:%S%Z'
@@ -90,10 +82,10 @@ OUT="$(mkstemp)"
printf '\n'
STATUS=0
- "$@" 2>&1 || STATUS=$?
+ "$@" || STATUS=$?
printf '\n'
printf '\nFinished at: %s\n' "$(now)"
-} 2>&1 1>"$OUT"
+} 1>"$OUT" 2>&1
email -s "(exit status: $STATUS) - $SUBJECT" eu@euandre.org < "$OUT"