| Here's another one: Provide explicit flags for default behavior. For example, if your lines-of-code counting utility excludes preprocessor directives by default, and includes them when you pass "-i", provide an "-x" switch that signals to use the default behavior. This way, when someone wants to write a bash script that uses your utility, they can do this: case $include_directives in
y)
LOC_FLAGS='-i';;
n)
LOC_FLAGS='-x';;
esac
myloc $LOC_FLAGS
This has three benefits:1.) It's explicit, and thus more obvious and clearer. 2.) It's more consistent, so there's no risk of empty/unset variables, whitespace, or other edge conditions screwing up a delicate munging operation. 3.) It's change-tolerant, so if future versions of your utility change the default behavior, scripts will continue functioning as expected. |