added code from book to shell.c