Functions will spill the return code to the console if unhandled and I see you don't handle it in your example. The command interpreter can, if called upon redirect output to nul but in your example you don't use it.

There are FAQs on both topics.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.