Do not silence stderr.
No need to wrap command -v in [[ ]].
Prefix all functions with function.
Use "$( )" over ` `.
Use ${var%/*} instead of dirname and ${var##*/} instead of basename.