#!/bin/sh printf '1..10\n' set -e holes() { "${HOLES:-./holes}" "$@"; } zeroes() { dd if=/dev/zero bs=${2:-1} count=$1 2>/dev/null; } nonzeroes() { zeroes $1 $2 | tr '\0' x; } check_output() { msg=$1 expected="$(cat)" shift if output="$(eval "$@" 2>&1)"; then if [ "$output" = "$expected" ]; then printf 'ok - %s\n' "$msg" return fi fi printf 'not ok - %s\n' "$msg" if [ "$output" != "$expected" ]; then printf 'Unexpected output:\n%s\n' "$output" | sed 's/^/# /' fi } check_output 'no hole' 'echo foobar | holes' <