fix bugs for command errors in MacOS X