Replace type with command -v (POSIX compliant), and add a test for executability, to determine whether an (executable) command exists.