--ERRORS: ERRORS is the number of errors to accumulate before outputing the error"
- errors=3
- while true; do
- if [[ $1 == --help ]]; then
- echo "$help"
- return
- elif [[ $1 == -[0-9]* ]]; then
- errors=${1#-}
- shift
- elif [[ $1 == -- ]]; then
- shift
- break
- else
- break
- fi
- done
- log_name=$1
- # todo, make option & make them overridable based on command line or env variable
- [[ -d $cbase ]] || mkdir -p $cbase
- c=$cbase/$log_name
- # http://stackoverflow.com/questions/2456750/detect-presence-of-stdin-contents-in-shell-script
- log=false
- if [[ $2 ]]; then
- log=true
- # read stdin for anything which is not just a newline
- elif [[ ! -t 0 ]]; then
- while read -r x; do
- output+=( $x )
- [[ $x ]] && log=true
- done
+-ERRORS: ERRORS is the number of errors to accumulate before outputing the error
+-v: Output the errors along the way to ERRORS
+
+
+You can emulate how cronjobs work by doing this for example:
+
+ cmdname |& log-once | ifne mail -s 'cmdname failed' root@localhost
+
+I could imagine a similar command that considers its non-option args to
+be an error, but I haven't written it yet.
+"
+ errors=3
+ mverr=0
+ verbose=false
+
+ while true; do
+ if [[ $1 == --help ]]; then
+ echo "$help"
+ return
+ elif [[ $1 == -v ]]; then
+ verbose=true
+ shift
+ elif [[ $1 == -[0-9]* ]]; then
+ errors=${1#-}
+ shift
+ elif [[ $1 == -- ]]; then
+ shift
+ break
+ else
+ break