summary refs log tree commit diff
path: root/bin/cronic
blob: 804f8035b73e6d7508e283694b14a9f05dc6338a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

set -e
[ -n "$DEBUG" ] && set -x

guienter=
while getopts Gh opt; do
	case "$opt" in
	G) guienter=1 ;;
	h | ?)
		printf "usage: %s [ARGS...]\n" "$(basename "$0")"
		printf "\n"
		printf "converts reasonably behaved programs that return a nonzero exit status\n"
		printf "into the back-asswards behavior cron expects, which is that printing text\n"
		printf "to stdout means an error occurred and any status code, successful or not,\n"
		printf "is disregarded.\n"
		printf "\n"
		printf "  -G  gui-enter as current user\n"
		printf "\n"
		exit 2
		;;
	esac
done
shift $((OPTIND - 1))

if [ -n "$guienter" ]; then
	set -- /home/robert/bin/gui-enter "$(id -un)" "$@"
fi

"$@" 1>&2 || printf "error. check stderr\n"