Thank you, Jon. Apple should have included this in Mac OS X. The 'open' command has been in since NeXTSTEP. Why not 'quit'?
Anyhow, I added an option '-f' which says to *not* print an error message if the requested app is not running. Following is the 'diff' output which shows the difference between Jon's original and mine. Users can add this option to the script using the 'patch' command on their Mac.
Here's the patch text, created by diff. I hope that MacUpdate's system doesn't munge it up.
> # This is Jon's version 1.3, with the -f option added by
> # Jerry Krinock, 20110325
< echo "Usage: `basename "$0"` [-a] [-p] [-s|n] "
> echo "Usage: `basename "$0"` [-a] [-p] [-s|n] [-f] "
> echo " -f Do not print an error message if app is not running"
< while getopts "apns" opt
> while getopts "apnsf" opt
> f) ignoreNotRunning="true" ;;
< echo "No running application matches \"$arg\""
> if [[ $ignoreNotRunning == "false" ]]
> echo "No running application matches \"$arg\""