shell.c: add static for internal functions, and improve readability

Details for readability
1. Add more comments
2. Reorder codes to separate internal functions, command handlers,
   and shell task