shell.c redirector handling seperated into a function