#!/bin/bash # Verify status and help message when running without arguments. if [[ $# != 1 ]]; then echo "$0 " exit 1 fi SPLITTER=$1 MSG=$(mktemp -p .) function die { echo "$1" rm -f "$MSG" exit 1 } # Test zero arguments. if ( "./$SPLITTER" > "$MSG" ); then die "$LINENO: Unexpected success." fi if ! ( grep -qi "in.*png.*out.*png.*out.*png" "$MSG" ); then die "$LINENO: Missing help message." fi # Test one argument. if ( "./$SPLITTER" unused1 > "$MSG" ); then die "$LINENO: Unexpected success." fi if ! ( grep -qi "in.*png.*out.*png.*out.*png" "$MSG" ); then die "$LINENO: Missing help message." fi # Test two arguments. if ( "./$SPLITTER" unused1 unused2 > "$MSG" ); then die "$LINENO: Unexpected success." fi if ! ( grep -qi "in.*png.*out.*png.*out.*png" "$MSG" ); then die "$LINENO: Missing help message." fi rm -f "$MSG" exit 0