arrange shell.c to improve readability