Avoid using 'function', which is not supported by all shells, and test that some argument is actually supplied.