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.
Basic tutorial:
http://www.linuxtutorialblog.com/post/introduction-using-diff-and-patch-tutorial
Intermediate tutorial:
http://www.linuxtutorialblog.com/post/introduction-using-diff-and-patch-tutorial
Here's the patch text, created by diff. I hope that MacUpdate's system doesn't munge it up.
22a23,25
> #
> # This is Jon's version 1.3, with the -f option added by
> # Jerry Krinock, 20110325
27c30
< echo "Usage: `basename "$0"` [-a] [-p] [-s|n] "
---
> echo "Usage: `basename "$0"` [-a] [-p] [-s|n] [-f] "
44a48
> echo " -f Do not print an error message if app is not running"
166c170,171
< while getopts "apns" opt
---
> ignoreNotRunning="false"
> while getopts "apnsf" opt
172a178
> f) ignoreNotRunning="true" ;;
206c212,215
< echo "No running application matches \"$arg\""
---
> if [[ $ignoreNotRunning == "false" ]]
> then
> echo "No running application matches \"$arg\""
> fi