Listing 2

#!/bin/sh
eval `mgetopt ad: "$@"`
test "$opt_BAD" && exit 1

if [ "$opt_a" ]; then
    echo "a=$opt_a"
    ...
fi
if [ "$opt_d" ]; then
    echo "d=$opt_d"
    ...
fi