#!/bin/bash

set -eu
set -o pipefail;

files="$@"

# --effort:max was given a chicken and the egg problem for closing a file in an exception handler...
# Intentionally not quoting $files
if ! output=$(set -eu; set -o pipefail; findbugs -effort:min -high $files 2>&1)
then
    echo "$0: Nonzero exit code detected" 1>&2
    echo "$output" 1>&2
    exit 1
else
    if [ "$output" != "" ]
    then
        echo "$0: Zero exit code, but output found:" 1>&2
        echo "$output" 1>&2
        exit 1
    fi
fi