#!/bin/bash -e
# each-e: run a command on each file in a list, exit on error

CMD=()

while [ "$1" != : -a $# -gt 0 ]; do
        CMD+=("$1")
        shift
done

if [ "$1" != : ]; then
        echo >&2 "usage: `basename "$0"` command arg ... : file ..."
        exit 1
fi

shift

for A; do
	"${CMD[@]}" "$A"
done

wait    # in case using . parallel
