Rearrange code order to improve readability in shell.c
shell.c: add static for internal function, and improve readability